

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="hz">
  <meta name="keywords" content="">
  
    <meta name="description" content="在前面一个相关的文章中，已经介绍了uni-app的加载过程，也可以回顾一下大致的过程如下：  使用yarn start命令，会直接出发vue-cli-service活动起来，然后开始加载vue-cli相关的插件 其中uni的三个插件会被加载，并依次之心 同时我们发现，在小程序模式下，hbuilderx插件是不会被执行的 然后我们发现optimize插件在develop模式下是不会被执行的 因此我们">
<meta property="og:type" content="article">
<meta property="og:title" content="Uni-App的代码生成">
<meta property="og:url" content="https://blog.brzhang.club/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/index.html">
<meta property="og:site_name" content="心随我动">
<meta property="og:description" content="在前面一个相关的文章中，已经介绍了uni-app的加载过程，也可以回顾一下大致的过程如下：  使用yarn start命令，会直接出发vue-cli-service活动起来，然后开始加载vue-cli相关的插件 其中uni的三个插件会被加载，并依次之心 同时我们发现，在小程序模式下，hbuilderx插件是不会被执行的 然后我们发现optimize插件在develop模式下是不会被执行的 因此我们">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://blog.brzhang.club/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308094639839.png">
<meta property="og:image" content="https://blog.brzhang.club/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308100008826.png">
<meta property="og:image" content="https://blog.brzhang.club/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308114349787.png">
<meta property="og:image" content="https://blog.brzhang.club/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308143533022.png">
<meta property="article:published_time" content="2022-03-08T01:09:45.000Z">
<meta property="article:modified_time" content="2022-11-28T01:25:08.252Z">
<meta property="article:author" content="hz">
<meta property="article:tag" content="小程序">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://blog.brzhang.club/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308094639839.png">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>Uni-App的代码生成 - 心随我动</title><meta name="robots" content="noindex">

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"blog.brzhang.club","root":"/","version":"1.9.5","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"left","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 30vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Brzhang</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="Uni-App的代码生成"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        hz
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-03-08 09:09" pubdate>
          2022年3月8日 上午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          52k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          436 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="padding-left: 2rem; margin-right: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">Uni-App的代码生成</h1>
            
            
              <div class="markdown-body">
                
                <p>在前面一个相关的文章中，已经介绍了uni-app的加载过程，也可以回顾一下大致的过程如下：</p>
<ol>
<li>使用yarn start命令，会直接出发vue-cli-service活动起来，然后开始加载vue-cli相关的插件</li>
<li>其中uni的三个插件会被加载，并依次之心</li>
<li>同时我们发现，在小程序模式下，hbuilderx插件是不会被执行的</li>
<li>然后我们发现optimize插件在develop模式下是不会被执行的</li>
<li>因此我们发现只有vue-cli-plugin-uni这个插件会被执行，这里面做了一些列的准备工作，目的就是为了uni能够有一个编译为小程序的环境，他在执行完插件体之后，最终cli-service会转而调用@dcloudio&#x2F;vue-cli-plugin-uni&#x2F;commands&#x2F;build.js中的build方法，然后build方法在执行的过程中，会到@dcloudio&#x2F;vue-cli-plugin-uni&#x2F;lib&#x2F;mp&#x2F;index.js中执行去手机webpack的一些配置，汇总好继续build的构建。</li>
</ol>
<p>我们知道，在commands&#x2F;build.js的build方法最后，是返回了一个Promise，里面直接进来就是开始webpack的构建，传入的参数就是上文梳理的插件中收集到的webpackConfigs。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> &#123;<br>    <span class="hljs-title function_">webpack</span>(webpackConfigs, <span class="hljs-function">(<span class="hljs-params">err, stats</span>) =&gt;</span> &#123;<br>      <span class="hljs-keyword">if</span> (!runByHBuilderX &amp;&amp; !runByAliIde) &#123;<br>        <span class="hljs-title function_">stopSpinner</span>(<span class="hljs-literal">false</span>)<br>      &#125;<br>      <span class="hljs-keyword">if</span> (err) &#123;<br>        <span class="hljs-keyword">return</span> <span class="hljs-title function_">reject</span>(err)<br>      &#125;<br><br>      <span class="hljs-keyword">if</span> (stats.<span class="hljs-title function_">hasErrors</span>()) &#123;<br>        <span class="hljs-comment">/* eslint-disable prefer-promise-reject-errors */</span><br>        <span class="hljs-keyword">return</span> <span class="hljs-title function_">reject</span>(<span class="hljs-string">&#x27;Build failed with errors.&#x27;</span>)<br>      &#125;<br><br>      <span class="hljs-keyword">if</span> (!args.<span class="hljs-property">silent</span> &amp;&amp; (process.<span class="hljs-property">env</span>.<span class="hljs-property">UNI_PLATFORM</span> !== <span class="hljs-string">&#x27;app-plus&#x27;</span> || process.<span class="hljs-property">env</span>.<span class="hljs-property">UNI_AUTOMATOR_WS_ENDPOINT</span>)) &#123;<br>        <span class="hljs-keyword">const</span> targetDirShort = path.<span class="hljs-title function_">relative</span>(<br>          api.<span class="hljs-property">service</span>.<span class="hljs-property">context</span>,<br>          process.<span class="hljs-property">env</span>.<span class="hljs-property">UNI_OUTPUT_DIR</span><br>        )<br><br>        <span class="hljs-keyword">if</span> (!args.<span class="hljs-property">watch</span>) &#123;<br>          <span class="hljs-keyword">const</span> dirMsg = runByHBuilderX ? <span class="hljs-string">&#x27;&#x27;</span><br>            : <span class="hljs-string">`The <span class="hljs-subst">$&#123;chalk.cyan(targetDirShort)&#125;</span> directory is ready to be deployed.`</span><br>          <span class="hljs-title function_">done</span>(<span class="hljs-string">`Build complete. <span class="hljs-subst">$&#123;dirMsg&#125;</span>`</span>)<br><br>          <span class="hljs-keyword">if</span> (process.<span class="hljs-property">env</span>.<span class="hljs-property">UNI_PLATFORM</span> === <span class="hljs-string">&#x27;h5&#x27;</span> &amp;&amp; !isInHBuilderX) &#123;<br>            <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>()<br>            <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;欢迎将H5站部署到uniCloud前端网页托管平台，高速、免费、安全、省心，详见：&#x27;</span>)<br>            <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;https://uniapp.dcloud.io/uniCloud/hosting&#x27;</span>)<br>          &#125;<br>        &#125; <span class="hljs-keyword">else</span> &#123;<br>          <span class="hljs-keyword">const</span> dirMsg = runByHBuilderX ? <span class="hljs-string">&#x27;&#x27;</span> : <span class="hljs-string">`The <span class="hljs-subst">$&#123;chalk.cyan(targetDirShort)&#125;</span> directory is ready. `</span><br>          <span class="hljs-title function_">done</span>(<span class="hljs-string">`Build complete. <span class="hljs-subst">$&#123;dirMsg&#125;</span>Watching for changes...`</span>)<br>        &#125;<br>      &#125;<br><br>      <span class="hljs-title function_">resolve</span>()<br>    &#125;)<br>  &#125;)<br></code></pre></td></tr></table></figure>

<p>下面就来分析一下，uni-app是如何处理一个页面的。要了解整个过程，我们不妨对webpack打一个断点。</p>
<p><img src="/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308094639839.png" srcset="/img/loading.gif" lazyload alt="image-20220308094639839" loading="lazy" data-src="/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308094639839.png"></p>
<p>注意到这里，我们发现如果options是一个数组的话，那么，compiler会被包装成一个MultiCompiler。实际上也确实如此，我们的options就是一个数组。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(options)) &#123;<br>	compiler = <span class="hljs-keyword">new</span> <span class="hljs-title class_">MultiCompiler</span>(<br>		<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">from</span>(options).<span class="hljs-title function_">map</span>(<span class="hljs-function"><span class="hljs-params">options</span> =&gt;</span> <span class="hljs-title function_">webpack</span>(options))<br>	);<br>&#125;<br></code></pre></td></tr></table></figure>

<p>但是递归调用webpack的时候却没有传入callback，仔细看后面会发现</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">if</span> (callback) &#123;<br>		<span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> callback !== <span class="hljs-string">&quot;function&quot;</span>) &#123;<br>			<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Error</span>(<span class="hljs-string">&quot;Invalid argument: callback&quot;</span>);<br>		&#125;<br>		<span class="hljs-keyword">if</span> (<br>			options.<span class="hljs-property">watch</span> === <span class="hljs-literal">true</span> ||<br>			(<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(options) &amp;&amp; options.<span class="hljs-title function_">some</span>(<span class="hljs-function"><span class="hljs-params">o</span> =&gt;</span> o.<span class="hljs-property">watch</span>))<br>		) &#123;<br>			<span class="hljs-keyword">const</span> watchOptions = <span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(options)<br>				? options.<span class="hljs-title function_">map</span>(<span class="hljs-function"><span class="hljs-params">o</span> =&gt;</span> o.<span class="hljs-property">watchOptions</span> || &#123;&#125;)<br>				: options.<span class="hljs-property">watchOptions</span> || &#123;&#125;;<br>			<span class="hljs-keyword">return</span> compiler.<span class="hljs-title function_">watch</span>(watchOptions, callback);<br>		&#125;<br>		compiler.<span class="hljs-title function_">run</span>(callback);<br>	&#125;<br></code></pre></td></tr></table></figure>

<p>这说明MultiCompiler的包装过程不会真正的去编译，而是指构造compiler。</p>
<p>compile构造的过程会加载各种插件，这些插件我们当然可以自定义的加进来。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">if</span> (options.<span class="hljs-property">plugins</span> &amp;&amp; <span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(options.<span class="hljs-property">plugins</span>)) &#123;<br>			<span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> plugin <span class="hljs-keyword">of</span> options.<span class="hljs-property">plugins</span>) &#123;<br>				<span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> plugin === <span class="hljs-string">&quot;function&quot;</span>) &#123;<br>					plugin.<span class="hljs-title function_">call</span>(compiler, compiler);<br>				&#125; <span class="hljs-keyword">else</span> &#123;<br>					plugin.<span class="hljs-title function_">apply</span>(compiler);<br>				&#125;<br>			&#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>比如说，这里就有我们的自己定义的插件</p>
<p><img src="/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308100008826.png" srcset="/img/loading.gif" lazyload alt="image-20220308100008826" loading="lazy" data-src="/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308100008826.png"></p>
<p>ok到此为止，compile总算是构造出来了，从现在开始才进入到真正的编译环节。</p>
<p>刚刚提到，只有当webpack的callback参数非空的时候，才能进入到正在的编译环节。那么编译有两种方式:</p>
<ol>
<li>compiler.watch(watchOptions, callback);</li>
<li>compiler.run(callback);</li>
</ol>
<p>这取决如我们是否传入了watch模式，也就是npm 命令中的 <strong>–watch</strong> 参数，通常我们在开发模式下是会传的，因为，我们改动代码保存之后需要出发自动编译出新产物嘛，不然，难道改动一行代码，就要去手动编译一下吗，这个代价是在是太大了点把。</p>
<p>webpack的watch方式是这么玩的，构造了一Watching来执行编译，this参数其实就是传入的compiler</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-title function_">watch</span>(<span class="hljs-params">watchOptions, handler</span>) &#123;<br>		<span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">running</span>) <span class="hljs-keyword">return</span> <span class="hljs-title function_">handler</span>(<span class="hljs-keyword">new</span> <span class="hljs-title class_">ConcurrentCompilationError</span>());<br><br>		<span class="hljs-variable language_">this</span>.<span class="hljs-property">running</span> = <span class="hljs-literal">true</span>;<br>		<span class="hljs-variable language_">this</span>.<span class="hljs-property">watchMode</span> = <span class="hljs-literal">true</span>;<br>		<span class="hljs-variable language_">this</span>.<span class="hljs-property">fileTimestamps</span> = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Map</span>();<br>		<span class="hljs-variable language_">this</span>.<span class="hljs-property">contextTimestamps</span> = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Map</span>();<br>		<span class="hljs-variable language_">this</span>.<span class="hljs-property">removedFiles</span> = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Set</span>();<br>		<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Watching</span>(<span class="hljs-variable language_">this</span>, watchOptions, handler);<br>	&#125;<br></code></pre></td></tr></table></figure>

<p>最终是loader</p>
<p><img src="/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308114349787.png" srcset="/img/loading.gif" lazyload alt="image-20220308114349787" loading="lazy" data-src="/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308114349787.png"></p>
<p>来处理每一个页面文件</p>
<p>，而uni自己的loader在@cloudio&#x2F;webpack-uni-mp-loader&#x2F;lib&#x2F;main.js，实际上，是main-new.js</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">callback</span>(<span class="hljs-literal">null</span>,<br>        <span class="hljs-string">`</span><br><span class="hljs-string">import Vue from &#x27;vue&#x27;</span><br><span class="hljs-string">import Page from &#x27;./<span class="hljs-subst">$&#123;normalizePath(params.page)&#125;</span><span class="hljs-subst">$&#123;ext&#125;</span>&#x27;</span><br><span class="hljs-string">createPage(Page)</span><br><span class="hljs-string">`</span>, map)<br>    &#125;<br></code></pre></td></tr></table></figure>

<p>会经过很多loader的处理,比如中间会生成这样的代码</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-string">&#x27;import &#x27;</span>uni-pages<span class="hljs-string">&#x27;;</span><br><span class="hljs-string">import Vue from &#x27;</span>vue<span class="hljs-string">&#x27;</span><br><span class="hljs-string">import Page from &#x27;</span>./pages/home/home-list.<span class="hljs-property">vue</span><span class="hljs-string">&#x27;</span><br><span class="hljs-string">createPage(Page)&#x27;</span><br></code></pre></td></tr></table></figure>

<p>其中createPage是uni的运行时</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br><span class="line">462</span><br><span class="line">463</span><br><span class="line">464</span><br><span class="line">465</span><br><span class="line">466</span><br><span class="line">467</span><br><span class="line">468</span><br><span class="line">469</span><br><span class="line">470</span><br><span class="line">471</span><br><span class="line">472</span><br><span class="line">473</span><br><span class="line">474</span><br><span class="line">475</span><br><span class="line">476</span><br><span class="line">477</span><br><span class="line">478</span><br><span class="line">479</span><br><span class="line">480</span><br><span class="line">481</span><br><span class="line">482</span><br><span class="line">483</span><br><span class="line">484</span><br><span class="line">485</span><br><span class="line">486</span><br><span class="line">487</span><br><span class="line">488</span><br><span class="line">489</span><br><span class="line">490</span><br><span class="line">491</span><br><span class="line">492</span><br><span class="line">493</span><br><span class="line">494</span><br><span class="line">495</span><br><span class="line">496</span><br><span class="line">497</span><br><span class="line">498</span><br><span class="line">499</span><br><span class="line">500</span><br><span class="line">501</span><br><span class="line">502</span><br><span class="line">503</span><br><span class="line">504</span><br><span class="line">505</span><br><span class="line">506</span><br><span class="line">507</span><br><span class="line">508</span><br><span class="line">509</span><br><span class="line">510</span><br><span class="line">511</span><br><span class="line">512</span><br><span class="line">513</span><br><span class="line">514</span><br><span class="line">515</span><br><span class="line">516</span><br><span class="line">517</span><br><span class="line">518</span><br><span class="line">519</span><br><span class="line">520</span><br><span class="line">521</span><br><span class="line">522</span><br><span class="line">523</span><br><span class="line">524</span><br><span class="line">525</span><br><span class="line">526</span><br><span class="line">527</span><br><span class="line">528</span><br><span class="line">529</span><br><span class="line">530</span><br><span class="line">531</span><br><span class="line">532</span><br><span class="line">533</span><br><span class="line">534</span><br><span class="line">535</span><br><span class="line">536</span><br><span class="line">537</span><br><span class="line">538</span><br><span class="line">539</span><br><span class="line">540</span><br><span class="line">541</span><br><span class="line">542</span><br><span class="line">543</span><br><span class="line">544</span><br><span class="line">545</span><br><span class="line">546</span><br><span class="line">547</span><br><span class="line">548</span><br><span class="line">549</span><br><span class="line">550</span><br><span class="line">551</span><br><span class="line">552</span><br><span class="line">553</span><br><span class="line">554</span><br><span class="line">555</span><br><span class="line">556</span><br><span class="line">557</span><br><span class="line">558</span><br><span class="line">559</span><br><span class="line">560</span><br><span class="line">561</span><br><span class="line">562</span><br><span class="line">563</span><br><span class="line">564</span><br><span class="line">565</span><br><span class="line">566</span><br><span class="line">567</span><br><span class="line">568</span><br><span class="line">569</span><br><span class="line">570</span><br><span class="line">571</span><br><span class="line">572</span><br><span class="line">573</span><br><span class="line">574</span><br><span class="line">575</span><br><span class="line">576</span><br><span class="line">577</span><br><span class="line">578</span><br><span class="line">579</span><br><span class="line">580</span><br><span class="line">581</span><br><span class="line">582</span><br><span class="line">583</span><br><span class="line">584</span><br><span class="line">585</span><br><span class="line">586</span><br><span class="line">587</span><br><span class="line">588</span><br><span class="line">589</span><br><span class="line">590</span><br><span class="line">591</span><br><span class="line">592</span><br><span class="line">593</span><br><span class="line">594</span><br><span class="line">595</span><br><span class="line">596</span><br><span class="line">597</span><br><span class="line">598</span><br><span class="line">599</span><br><span class="line">600</span><br><span class="line">601</span><br><span class="line">602</span><br><span class="line">603</span><br><span class="line">604</span><br><span class="line">605</span><br><span class="line">606</span><br><span class="line">607</span><br><span class="line">608</span><br><span class="line">609</span><br><span class="line">610</span><br><span class="line">611</span><br><span class="line">612</span><br><span class="line">613</span><br><span class="line">614</span><br><span class="line">615</span><br><span class="line">616</span><br><span class="line">617</span><br><span class="line">618</span><br><span class="line">619</span><br><span class="line">620</span><br><span class="line">621</span><br><span class="line">622</span><br><span class="line">623</span><br><span class="line">624</span><br><span class="line">625</span><br><span class="line">626</span><br><span class="line">627</span><br><span class="line">628</span><br><span class="line">629</span><br><span class="line">630</span><br><span class="line">631</span><br><span class="line">632</span><br><span class="line">633</span><br><span class="line">634</span><br><span class="line">635</span><br><span class="line">636</span><br><span class="line">637</span><br><span class="line">638</span><br><span class="line">639</span><br><span class="line">640</span><br><span class="line">641</span><br><span class="line">642</span><br><span class="line">643</span><br><span class="line">644</span><br><span class="line">645</span><br><span class="line">646</span><br><span class="line">647</span><br><span class="line">648</span><br><span class="line">649</span><br><span class="line">650</span><br><span class="line">651</span><br><span class="line">652</span><br><span class="line">653</span><br><span class="line">654</span><br><span class="line">655</span><br><span class="line">656</span><br><span class="line">657</span><br><span class="line">658</span><br><span class="line">659</span><br><span class="line">660</span><br><span class="line">661</span><br><span class="line">662</span><br><span class="line">663</span><br><span class="line">664</span><br><span class="line">665</span><br><span class="line">666</span><br><span class="line">667</span><br><span class="line">668</span><br><span class="line">669</span><br><span class="line">670</span><br><span class="line">671</span><br><span class="line">672</span><br><span class="line">673</span><br><span class="line">674</span><br><span class="line">675</span><br><span class="line">676</span><br><span class="line">677</span><br><span class="line">678</span><br><span class="line">679</span><br><span class="line">680</span><br><span class="line">681</span><br><span class="line">682</span><br><span class="line">683</span><br><span class="line">684</span><br><span class="line">685</span><br><span class="line">686</span><br><span class="line">687</span><br><span class="line">688</span><br><span class="line">689</span><br><span class="line">690</span><br><span class="line">691</span><br><span class="line">692</span><br><span class="line">693</span><br><span class="line">694</span><br><span class="line">695</span><br><span class="line">696</span><br><span class="line">697</span><br><span class="line">698</span><br><span class="line">699</span><br><span class="line">700</span><br><span class="line">701</span><br><span class="line">702</span><br><span class="line">703</span><br><span class="line">704</span><br><span class="line">705</span><br><span class="line">706</span><br><span class="line">707</span><br><span class="line">708</span><br><span class="line">709</span><br><span class="line">710</span><br><span class="line">711</span><br><span class="line">712</span><br><span class="line">713</span><br><span class="line">714</span><br><span class="line">715</span><br><span class="line">716</span><br><span class="line">717</span><br><span class="line">718</span><br><span class="line">719</span><br><span class="line">720</span><br><span class="line">721</span><br><span class="line">722</span><br><span class="line">723</span><br><span class="line">724</span><br><span class="line">725</span><br><span class="line">726</span><br><span class="line">727</span><br><span class="line">728</span><br><span class="line">729</span><br><span class="line">730</span><br><span class="line">731</span><br><span class="line">732</span><br><span class="line">733</span><br><span class="line">734</span><br><span class="line">735</span><br><span class="line">736</span><br><span class="line">737</span><br><span class="line">738</span><br><span class="line">739</span><br><span class="line">740</span><br><span class="line">741</span><br><span class="line">742</span><br><span class="line">743</span><br><span class="line">744</span><br><span class="line">745</span><br><span class="line">746</span><br><span class="line">747</span><br><span class="line">748</span><br><span class="line">749</span><br><span class="line">750</span><br><span class="line">751</span><br><span class="line">752</span><br><span class="line">753</span><br><span class="line">754</span><br><span class="line">755</span><br><span class="line">756</span><br><span class="line">757</span><br><span class="line">758</span><br><span class="line">759</span><br><span class="line">760</span><br><span class="line">761</span><br><span class="line">762</span><br><span class="line">763</span><br><span class="line">764</span><br><span class="line">765</span><br><span class="line">766</span><br><span class="line">767</span><br><span class="line">768</span><br><span class="line">769</span><br><span class="line">770</span><br><span class="line">771</span><br><span class="line">772</span><br><span class="line">773</span><br><span class="line">774</span><br><span class="line">775</span><br><span class="line">776</span><br><span class="line">777</span><br><span class="line">778</span><br><span class="line">779</span><br><span class="line">780</span><br><span class="line">781</span><br><span class="line">782</span><br><span class="line">783</span><br><span class="line">784</span><br><span class="line">785</span><br><span class="line">786</span><br><span class="line">787</span><br><span class="line">788</span><br><span class="line">789</span><br><span class="line">790</span><br><span class="line">791</span><br><span class="line">792</span><br><span class="line">793</span><br><span class="line">794</span><br><span class="line">795</span><br><span class="line">796</span><br><span class="line">797</span><br><span class="line">798</span><br><span class="line">799</span><br><span class="line">800</span><br><span class="line">801</span><br><span class="line">802</span><br><span class="line">803</span><br><span class="line">804</span><br><span class="line">805</span><br><span class="line">806</span><br><span class="line">807</span><br><span class="line">808</span><br><span class="line">809</span><br><span class="line">810</span><br><span class="line">811</span><br><span class="line">812</span><br><span class="line">813</span><br><span class="line">814</span><br><span class="line">815</span><br><span class="line">816</span><br><span class="line">817</span><br><span class="line">818</span><br><span class="line">819</span><br><span class="line">820</span><br><span class="line">821</span><br><span class="line">822</span><br><span class="line">823</span><br><span class="line">824</span><br><span class="line">825</span><br><span class="line">826</span><br><span class="line">827</span><br><span class="line">828</span><br><span class="line">829</span><br><span class="line">830</span><br><span class="line">831</span><br><span class="line">832</span><br><span class="line">833</span><br><span class="line">834</span><br><span class="line">835</span><br><span class="line">836</span><br><span class="line">837</span><br><span class="line">838</span><br><span class="line">839</span><br><span class="line">840</span><br><span class="line">841</span><br><span class="line">842</span><br><span class="line">843</span><br><span class="line">844</span><br><span class="line">845</span><br><span class="line">846</span><br><span class="line">847</span><br><span class="line">848</span><br><span class="line">849</span><br><span class="line">850</span><br><span class="line">851</span><br><span class="line">852</span><br><span class="line">853</span><br><span class="line">854</span><br><span class="line">855</span><br><span class="line">856</span><br><span class="line">857</span><br><span class="line">858</span><br><span class="line">859</span><br><span class="line">860</span><br><span class="line">861</span><br><span class="line">862</span><br><span class="line">863</span><br><span class="line">864</span><br><span class="line">865</span><br><span class="line">866</span><br><span class="line">867</span><br><span class="line">868</span><br><span class="line">869</span><br><span class="line">870</span><br><span class="line">871</span><br><span class="line">872</span><br><span class="line">873</span><br><span class="line">874</span><br><span class="line">875</span><br><span class="line">876</span><br><span class="line">877</span><br><span class="line">878</span><br><span class="line">879</span><br><span class="line">880</span><br><span class="line">881</span><br><span class="line">882</span><br><span class="line">883</span><br><span class="line">884</span><br><span class="line">885</span><br><span class="line">886</span><br><span class="line">887</span><br><span class="line">888</span><br><span class="line">889</span><br><span class="line">890</span><br><span class="line">891</span><br><span class="line">892</span><br><span class="line">893</span><br><span class="line">894</span><br><span class="line">895</span><br><span class="line">896</span><br><span class="line">897</span><br><span class="line">898</span><br><span class="line">899</span><br><span class="line">900</span><br><span class="line">901</span><br><span class="line">902</span><br><span class="line">903</span><br><span class="line">904</span><br><span class="line">905</span><br><span class="line">906</span><br><span class="line">907</span><br><span class="line">908</span><br><span class="line">909</span><br><span class="line">910</span><br><span class="line">911</span><br><span class="line">912</span><br><span class="line">913</span><br><span class="line">914</span><br><span class="line">915</span><br><span class="line">916</span><br><span class="line">917</span><br><span class="line">918</span><br><span class="line">919</span><br><span class="line">920</span><br><span class="line">921</span><br><span class="line">922</span><br><span class="line">923</span><br><span class="line">924</span><br><span class="line">925</span><br><span class="line">926</span><br><span class="line">927</span><br><span class="line">928</span><br><span class="line">929</span><br><span class="line">930</span><br><span class="line">931</span><br><span class="line">932</span><br><span class="line">933</span><br><span class="line">934</span><br><span class="line">935</span><br><span class="line">936</span><br><span class="line">937</span><br><span class="line">938</span><br><span class="line">939</span><br><span class="line">940</span><br><span class="line">941</span><br><span class="line">942</span><br><span class="line">943</span><br><span class="line">944</span><br><span class="line">945</span><br><span class="line">946</span><br><span class="line">947</span><br><span class="line">948</span><br><span class="line">949</span><br><span class="line">950</span><br><span class="line">951</span><br><span class="line">952</span><br><span class="line">953</span><br><span class="line">954</span><br><span class="line">955</span><br><span class="line">956</span><br><span class="line">957</span><br><span class="line">958</span><br><span class="line">959</span><br><span class="line">960</span><br><span class="line">961</span><br><span class="line">962</span><br><span class="line">963</span><br><span class="line">964</span><br><span class="line">965</span><br><span class="line">966</span><br><span class="line">967</span><br><span class="line">968</span><br><span class="line">969</span><br><span class="line">970</span><br><span class="line">971</span><br><span class="line">972</span><br><span class="line">973</span><br><span class="line">974</span><br><span class="line">975</span><br><span class="line">976</span><br><span class="line">977</span><br><span class="line">978</span><br><span class="line">979</span><br><span class="line">980</span><br><span class="line">981</span><br><span class="line">982</span><br><span class="line">983</span><br><span class="line">984</span><br><span class="line">985</span><br><span class="line">986</span><br><span class="line">987</span><br><span class="line">988</span><br><span class="line">989</span><br><span class="line">990</span><br><span class="line">991</span><br><span class="line">992</span><br><span class="line">993</span><br><span class="line">994</span><br><span class="line">995</span><br><span class="line">996</span><br><span class="line">997</span><br><span class="line">998</span><br><span class="line">999</span><br><span class="line">1000</span><br><span class="line">1001</span><br><span class="line">1002</span><br><span class="line">1003</span><br><span class="line">1004</span><br><span class="line">1005</span><br><span class="line">1006</span><br><span class="line">1007</span><br><span class="line">1008</span><br><span class="line">1009</span><br><span class="line">1010</span><br><span class="line">1011</span><br><span class="line">1012</span><br><span class="line">1013</span><br><span class="line">1014</span><br><span class="line">1015</span><br><span class="line">1016</span><br><span class="line">1017</span><br><span class="line">1018</span><br><span class="line">1019</span><br><span class="line">1020</span><br><span class="line">1021</span><br><span class="line">1022</span><br><span class="line">1023</span><br><span class="line">1024</span><br><span class="line">1025</span><br><span class="line">1026</span><br><span class="line">1027</span><br><span class="line">1028</span><br><span class="line">1029</span><br><span class="line">1030</span><br><span class="line">1031</span><br><span class="line">1032</span><br><span class="line">1033</span><br><span class="line">1034</span><br><span class="line">1035</span><br><span class="line">1036</span><br><span class="line">1037</span><br><span class="line">1038</span><br><span class="line">1039</span><br><span class="line">1040</span><br><span class="line">1041</span><br><span class="line">1042</span><br><span class="line">1043</span><br><span class="line">1044</span><br><span class="line">1045</span><br><span class="line">1046</span><br><span class="line">1047</span><br><span class="line">1048</span><br><span class="line">1049</span><br><span class="line">1050</span><br><span class="line">1051</span><br><span class="line">1052</span><br><span class="line">1053</span><br><span class="line">1054</span><br><span class="line">1055</span><br><span class="line">1056</span><br><span class="line">1057</span><br><span class="line">1058</span><br><span class="line">1059</span><br><span class="line">1060</span><br><span class="line">1061</span><br><span class="line">1062</span><br><span class="line">1063</span><br><span class="line">1064</span><br><span class="line">1065</span><br><span class="line">1066</span><br><span class="line">1067</span><br><span class="line">1068</span><br><span class="line">1069</span><br><span class="line">1070</span><br><span class="line">1071</span><br><span class="line">1072</span><br><span class="line">1073</span><br><span class="line">1074</span><br><span class="line">1075</span><br><span class="line">1076</span><br><span class="line">1077</span><br><span class="line">1078</span><br><span class="line">1079</span><br><span class="line">1080</span><br><span class="line">1081</span><br><span class="line">1082</span><br><span class="line">1083</span><br><span class="line">1084</span><br><span class="line">1085</span><br><span class="line">1086</span><br><span class="line">1087</span><br><span class="line">1088</span><br><span class="line">1089</span><br><span class="line">1090</span><br><span class="line">1091</span><br><span class="line">1092</span><br><span class="line">1093</span><br><span class="line">1094</span><br><span class="line">1095</span><br><span class="line">1096</span><br><span class="line">1097</span><br><span class="line">1098</span><br><span class="line">1099</span><br><span class="line">1100</span><br><span class="line">1101</span><br><span class="line">1102</span><br><span class="line">1103</span><br><span class="line">1104</span><br><span class="line">1105</span><br><span class="line">1106</span><br><span class="line">1107</span><br><span class="line">1108</span><br><span class="line">1109</span><br><span class="line">1110</span><br><span class="line">1111</span><br><span class="line">1112</span><br><span class="line">1113</span><br><span class="line">1114</span><br><span class="line">1115</span><br><span class="line">1116</span><br><span class="line">1117</span><br><span class="line">1118</span><br><span class="line">1119</span><br><span class="line">1120</span><br><span class="line">1121</span><br><span class="line">1122</span><br><span class="line">1123</span><br><span class="line">1124</span><br><span class="line">1125</span><br><span class="line">1126</span><br><span class="line">1127</span><br><span class="line">1128</span><br><span class="line">1129</span><br><span class="line">1130</span><br><span class="line">1131</span><br><span class="line">1132</span><br><span class="line">1133</span><br><span class="line">1134</span><br><span class="line">1135</span><br><span class="line">1136</span><br><span class="line">1137</span><br><span class="line">1138</span><br><span class="line">1139</span><br><span class="line">1140</span><br><span class="line">1141</span><br><span class="line">1142</span><br><span class="line">1143</span><br><span class="line">1144</span><br><span class="line">1145</span><br><span class="line">1146</span><br><span class="line">1147</span><br><span class="line">1148</span><br><span class="line">1149</span><br><span class="line">1150</span><br><span class="line">1151</span><br><span class="line">1152</span><br><span class="line">1153</span><br><span class="line">1154</span><br><span class="line">1155</span><br><span class="line">1156</span><br><span class="line">1157</span><br><span class="line">1158</span><br><span class="line">1159</span><br><span class="line">1160</span><br><span class="line">1161</span><br><span class="line">1162</span><br><span class="line">1163</span><br><span class="line">1164</span><br><span class="line">1165</span><br><span class="line">1166</span><br><span class="line">1167</span><br><span class="line">1168</span><br><span class="line">1169</span><br><span class="line">1170</span><br><span class="line">1171</span><br><span class="line">1172</span><br><span class="line">1173</span><br><span class="line">1174</span><br><span class="line">1175</span><br><span class="line">1176</span><br><span class="line">1177</span><br><span class="line">1178</span><br><span class="line">1179</span><br><span class="line">1180</span><br><span class="line">1181</span><br><span class="line">1182</span><br><span class="line">1183</span><br><span class="line">1184</span><br><span class="line">1185</span><br><span class="line">1186</span><br><span class="line">1187</span><br><span class="line">1188</span><br><span class="line">1189</span><br><span class="line">1190</span><br><span class="line">1191</span><br><span class="line">1192</span><br><span class="line">1193</span><br><span class="line">1194</span><br><span class="line">1195</span><br><span class="line">1196</span><br><span class="line">1197</span><br><span class="line">1198</span><br><span class="line">1199</span><br><span class="line">1200</span><br><span class="line">1201</span><br><span class="line">1202</span><br><span class="line">1203</span><br><span class="line">1204</span><br><span class="line">1205</span><br><span class="line">1206</span><br><span class="line">1207</span><br><span class="line">1208</span><br><span class="line">1209</span><br><span class="line">1210</span><br><span class="line">1211</span><br><span class="line">1212</span><br><span class="line">1213</span><br><span class="line">1214</span><br><span class="line">1215</span><br><span class="line">1216</span><br><span class="line">1217</span><br><span class="line">1218</span><br><span class="line">1219</span><br><span class="line">1220</span><br><span class="line">1221</span><br><span class="line">1222</span><br><span class="line">1223</span><br><span class="line">1224</span><br><span class="line">1225</span><br><span class="line">1226</span><br><span class="line">1227</span><br><span class="line">1228</span><br><span class="line">1229</span><br><span class="line">1230</span><br><span class="line">1231</span><br><span class="line">1232</span><br><span class="line">1233</span><br><span class="line">1234</span><br><span class="line">1235</span><br><span class="line">1236</span><br><span class="line">1237</span><br><span class="line">1238</span><br><span class="line">1239</span><br><span class="line">1240</span><br><span class="line">1241</span><br><span class="line">1242</span><br><span class="line">1243</span><br><span class="line">1244</span><br><span class="line">1245</span><br><span class="line">1246</span><br><span class="line">1247</span><br><span class="line">1248</span><br><span class="line">1249</span><br><span class="line">1250</span><br><span class="line">1251</span><br><span class="line">1252</span><br><span class="line">1253</span><br><span class="line">1254</span><br><span class="line">1255</span><br><span class="line">1256</span><br><span class="line">1257</span><br><span class="line">1258</span><br><span class="line">1259</span><br><span class="line">1260</span><br><span class="line">1261</span><br><span class="line">1262</span><br><span class="line">1263</span><br><span class="line">1264</span><br><span class="line">1265</span><br><span class="line">1266</span><br><span class="line">1267</span><br><span class="line">1268</span><br><span class="line">1269</span><br><span class="line">1270</span><br><span class="line">1271</span><br><span class="line">1272</span><br><span class="line">1273</span><br><span class="line">1274</span><br><span class="line">1275</span><br><span class="line">1276</span><br><span class="line">1277</span><br><span class="line">1278</span><br><span class="line">1279</span><br><span class="line">1280</span><br><span class="line">1281</span><br><span class="line">1282</span><br><span class="line">1283</span><br><span class="line">1284</span><br><span class="line">1285</span><br><span class="line">1286</span><br><span class="line">1287</span><br><span class="line">1288</span><br><span class="line">1289</span><br><span class="line">1290</span><br><span class="line">1291</span><br><span class="line">1292</span><br><span class="line">1293</span><br><span class="line">1294</span><br><span class="line">1295</span><br><span class="line">1296</span><br><span class="line">1297</span><br><span class="line">1298</span><br><span class="line">1299</span><br><span class="line">1300</span><br><span class="line">1301</span><br><span class="line">1302</span><br><span class="line">1303</span><br><span class="line">1304</span><br><span class="line">1305</span><br><span class="line">1306</span><br><span class="line">1307</span><br><span class="line">1308</span><br><span class="line">1309</span><br><span class="line">1310</span><br><span class="line">1311</span><br><span class="line">1312</span><br><span class="line">1313</span><br><span class="line">1314</span><br><span class="line">1315</span><br><span class="line">1316</span><br><span class="line">1317</span><br><span class="line">1318</span><br><span class="line">1319</span><br><span class="line">1320</span><br><span class="line">1321</span><br><span class="line">1322</span><br><span class="line">1323</span><br><span class="line">1324</span><br><span class="line">1325</span><br><span class="line">1326</span><br><span class="line">1327</span><br><span class="line">1328</span><br><span class="line">1329</span><br><span class="line">1330</span><br><span class="line">1331</span><br><span class="line">1332</span><br><span class="line">1333</span><br><span class="line">1334</span><br><span class="line">1335</span><br><span class="line">1336</span><br><span class="line">1337</span><br><span class="line">1338</span><br><span class="line">1339</span><br><span class="line">1340</span><br><span class="line">1341</span><br><span class="line">1342</span><br><span class="line">1343</span><br><span class="line">1344</span><br><span class="line">1345</span><br><span class="line">1346</span><br><span class="line">1347</span><br><span class="line">1348</span><br><span class="line">1349</span><br><span class="line">1350</span><br><span class="line">1351</span><br><span class="line">1352</span><br><span class="line">1353</span><br><span class="line">1354</span><br><span class="line">1355</span><br><span class="line">1356</span><br><span class="line">1357</span><br><span class="line">1358</span><br><span class="line">1359</span><br><span class="line">1360</span><br><span class="line">1361</span><br><span class="line">1362</span><br><span class="line">1363</span><br><span class="line">1364</span><br><span class="line">1365</span><br><span class="line">1366</span><br><span class="line">1367</span><br><span class="line">1368</span><br><span class="line">1369</span><br><span class="line">1370</span><br><span class="line">1371</span><br><span class="line">1372</span><br><span class="line">1373</span><br><span class="line">1374</span><br><span class="line">1375</span><br><span class="line">1376</span><br><span class="line">1377</span><br><span class="line">1378</span><br><span class="line">1379</span><br><span class="line">1380</span><br><span class="line">1381</span><br><span class="line">1382</span><br><span class="line">1383</span><br><span class="line">1384</span><br><span class="line">1385</span><br><span class="line">1386</span><br><span class="line">1387</span><br><span class="line">1388</span><br><span class="line">1389</span><br><span class="line">1390</span><br><span class="line">1391</span><br><span class="line">1392</span><br><span class="line">1393</span><br><span class="line">1394</span><br><span class="line">1395</span><br><span class="line">1396</span><br><span class="line">1397</span><br><span class="line">1398</span><br><span class="line">1399</span><br><span class="line">1400</span><br><span class="line">1401</span><br><span class="line">1402</span><br><span class="line">1403</span><br><span class="line">1404</span><br><span class="line">1405</span><br><span class="line">1406</span><br><span class="line">1407</span><br><span class="line">1408</span><br><span class="line">1409</span><br><span class="line">1410</span><br><span class="line">1411</span><br><span class="line">1412</span><br><span class="line">1413</span><br><span class="line">1414</span><br><span class="line">1415</span><br><span class="line">1416</span><br><span class="line">1417</span><br><span class="line">1418</span><br><span class="line">1419</span><br><span class="line">1420</span><br><span class="line">1421</span><br><span class="line">1422</span><br><span class="line">1423</span><br><span class="line">1424</span><br><span class="line">1425</span><br><span class="line">1426</span><br><span class="line">1427</span><br><span class="line">1428</span><br><span class="line">1429</span><br><span class="line">1430</span><br><span class="line">1431</span><br><span class="line">1432</span><br><span class="line">1433</span><br><span class="line">1434</span><br><span class="line">1435</span><br><span class="line">1436</span><br><span class="line">1437</span><br><span class="line">1438</span><br><span class="line">1439</span><br><span class="line">1440</span><br><span class="line">1441</span><br><span class="line">1442</span><br><span class="line">1443</span><br><span class="line">1444</span><br><span class="line">1445</span><br><span class="line">1446</span><br><span class="line">1447</span><br><span class="line">1448</span><br><span class="line">1449</span><br><span class="line">1450</span><br><span class="line">1451</span><br><span class="line">1452</span><br><span class="line">1453</span><br><span class="line">1454</span><br><span class="line">1455</span><br><span class="line">1456</span><br><span class="line">1457</span><br><span class="line">1458</span><br><span class="line">1459</span><br><span class="line">1460</span><br><span class="line">1461</span><br><span class="line">1462</span><br><span class="line">1463</span><br><span class="line">1464</span><br><span class="line">1465</span><br><span class="line">1466</span><br><span class="line">1467</span><br><span class="line">1468</span><br><span class="line">1469</span><br><span class="line">1470</span><br><span class="line">1471</span><br><span class="line">1472</span><br><span class="line">1473</span><br><span class="line">1474</span><br><span class="line">1475</span><br><span class="line">1476</span><br><span class="line">1477</span><br><span class="line">1478</span><br><span class="line">1479</span><br><span class="line">1480</span><br><span class="line">1481</span><br><span class="line">1482</span><br><span class="line">1483</span><br><span class="line">1484</span><br><span class="line">1485</span><br><span class="line">1486</span><br><span class="line">1487</span><br><span class="line">1488</span><br><span class="line">1489</span><br><span class="line">1490</span><br><span class="line">1491</span><br><span class="line">1492</span><br><span class="line">1493</span><br><span class="line">1494</span><br><span class="line">1495</span><br><span class="line">1496</span><br><span class="line">1497</span><br><span class="line">1498</span><br><span class="line">1499</span><br><span class="line">1500</span><br><span class="line">1501</span><br><span class="line">1502</span><br><span class="line">1503</span><br><span class="line">1504</span><br><span class="line">1505</span><br><span class="line">1506</span><br><span class="line">1507</span><br><span class="line">1508</span><br><span class="line">1509</span><br><span class="line">1510</span><br><span class="line">1511</span><br><span class="line">1512</span><br><span class="line">1513</span><br><span class="line">1514</span><br><span class="line">1515</span><br><span class="line">1516</span><br><span class="line">1517</span><br><span class="line">1518</span><br><span class="line">1519</span><br><span class="line">1520</span><br><span class="line">1521</span><br><span class="line">1522</span><br><span class="line">1523</span><br><span class="line">1524</span><br><span class="line">1525</span><br><span class="line">1526</span><br><span class="line">1527</span><br><span class="line">1528</span><br><span class="line">1529</span><br><span class="line">1530</span><br><span class="line">1531</span><br><span class="line">1532</span><br><span class="line">1533</span><br><span class="line">1534</span><br><span class="line">1535</span><br><span class="line">1536</span><br><span class="line">1537</span><br><span class="line">1538</span><br><span class="line">1539</span><br><span class="line">1540</span><br><span class="line">1541</span><br><span class="line">1542</span><br><span class="line">1543</span><br><span class="line">1544</span><br><span class="line">1545</span><br><span class="line">1546</span><br><span class="line">1547</span><br><span class="line">1548</span><br><span class="line">1549</span><br><span class="line">1550</span><br><span class="line">1551</span><br><span class="line">1552</span><br><span class="line">1553</span><br><span class="line">1554</span><br><span class="line">1555</span><br><span class="line">1556</span><br><span class="line">1557</span><br><span class="line">1558</span><br><span class="line">1559</span><br><span class="line">1560</span><br><span class="line">1561</span><br><span class="line">1562</span><br><span class="line">1563</span><br><span class="line">1564</span><br><span class="line">1565</span><br><span class="line">1566</span><br><span class="line">1567</span><br><span class="line">1568</span><br><span class="line">1569</span><br><span class="line">1570</span><br><span class="line">1571</span><br><span class="line">1572</span><br><span class="line">1573</span><br><span class="line">1574</span><br><span class="line">1575</span><br><span class="line">1576</span><br><span class="line">1577</span><br><span class="line">1578</span><br><span class="line">1579</span><br><span class="line">1580</span><br><span class="line">1581</span><br><span class="line">1582</span><br><span class="line">1583</span><br><span class="line">1584</span><br><span class="line">1585</span><br><span class="line">1586</span><br><span class="line">1587</span><br><span class="line">1588</span><br><span class="line">1589</span><br><span class="line">1590</span><br><span class="line">1591</span><br><span class="line">1592</span><br><span class="line">1593</span><br><span class="line">1594</span><br><span class="line">1595</span><br><span class="line">1596</span><br><span class="line">1597</span><br><span class="line">1598</span><br><span class="line">1599</span><br><span class="line">1600</span><br><span class="line">1601</span><br><span class="line">1602</span><br><span class="line">1603</span><br><span class="line">1604</span><br><span class="line">1605</span><br><span class="line">1606</span><br><span class="line">1607</span><br><span class="line">1608</span><br><span class="line">1609</span><br><span class="line">1610</span><br><span class="line">1611</span><br><span class="line">1612</span><br><span class="line">1613</span><br><span class="line">1614</span><br><span class="line">1615</span><br><span class="line">1616</span><br><span class="line">1617</span><br><span class="line">1618</span><br><span class="line">1619</span><br><span class="line">1620</span><br><span class="line">1621</span><br><span class="line">1622</span><br><span class="line">1623</span><br><span class="line">1624</span><br><span class="line">1625</span><br><span class="line">1626</span><br><span class="line">1627</span><br><span class="line">1628</span><br><span class="line">1629</span><br><span class="line">1630</span><br><span class="line">1631</span><br><span class="line">1632</span><br><span class="line">1633</span><br><span class="line">1634</span><br><span class="line">1635</span><br><span class="line">1636</span><br><span class="line">1637</span><br><span class="line">1638</span><br><span class="line">1639</span><br><span class="line">1640</span><br><span class="line">1641</span><br><span class="line">1642</span><br><span class="line">1643</span><br><span class="line">1644</span><br><span class="line">1645</span><br><span class="line">1646</span><br><span class="line">1647</span><br><span class="line">1648</span><br><span class="line">1649</span><br><span class="line">1650</span><br><span class="line">1651</span><br><span class="line">1652</span><br><span class="line">1653</span><br><span class="line">1654</span><br><span class="line">1655</span><br><span class="line">1656</span><br><span class="line">1657</span><br><span class="line">1658</span><br><span class="line">1659</span><br><span class="line">1660</span><br><span class="line">1661</span><br><span class="line">1662</span><br><span class="line">1663</span><br><span class="line">1664</span><br><span class="line">1665</span><br><span class="line">1666</span><br><span class="line">1667</span><br><span class="line">1668</span><br><span class="line">1669</span><br><span class="line">1670</span><br><span class="line">1671</span><br><span class="line">1672</span><br><span class="line">1673</span><br><span class="line">1674</span><br><span class="line">1675</span><br><span class="line">1676</span><br><span class="line">1677</span><br><span class="line">1678</span><br><span class="line">1679</span><br><span class="line">1680</span><br><span class="line">1681</span><br><span class="line">1682</span><br><span class="line">1683</span><br><span class="line">1684</span><br><span class="line">1685</span><br><span class="line">1686</span><br><span class="line">1687</span><br><span class="line">1688</span><br><span class="line">1689</span><br><span class="line">1690</span><br><span class="line">1691</span><br><span class="line">1692</span><br><span class="line">1693</span><br><span class="line">1694</span><br><span class="line">1695</span><br><span class="line">1696</span><br><span class="line">1697</span><br><span class="line">1698</span><br><span class="line">1699</span><br><span class="line">1700</span><br><span class="line">1701</span><br><span class="line">1702</span><br><span class="line">1703</span><br><span class="line">1704</span><br><span class="line">1705</span><br><span class="line">1706</span><br><span class="line">1707</span><br><span class="line">1708</span><br><span class="line">1709</span><br><span class="line">1710</span><br><span class="line">1711</span><br><span class="line">1712</span><br><span class="line">1713</span><br><span class="line">1714</span><br><span class="line">1715</span><br><span class="line">1716</span><br><span class="line">1717</span><br><span class="line">1718</span><br><span class="line">1719</span><br><span class="line">1720</span><br><span class="line">1721</span><br><span class="line">1722</span><br><span class="line">1723</span><br><span class="line">1724</span><br><span class="line">1725</span><br><span class="line">1726</span><br><span class="line">1727</span><br><span class="line">1728</span><br><span class="line">1729</span><br><span class="line">1730</span><br><span class="line">1731</span><br><span class="line">1732</span><br><span class="line">1733</span><br><span class="line">1734</span><br><span class="line">1735</span><br><span class="line">1736</span><br><span class="line">1737</span><br><span class="line">1738</span><br><span class="line">1739</span><br><span class="line">1740</span><br><span class="line">1741</span><br><span class="line">1742</span><br><span class="line">1743</span><br><span class="line">1744</span><br><span class="line">1745</span><br><span class="line">1746</span><br><span class="line">1747</span><br><span class="line">1748</span><br><span class="line">1749</span><br><span class="line">1750</span><br><span class="line">1751</span><br><span class="line">1752</span><br><span class="line">1753</span><br><span class="line">1754</span><br><span class="line">1755</span><br><span class="line">1756</span><br><span class="line">1757</span><br><span class="line">1758</span><br><span class="line">1759</span><br><span class="line">1760</span><br><span class="line">1761</span><br><span class="line">1762</span><br><span class="line">1763</span><br><span class="line">1764</span><br><span class="line">1765</span><br><span class="line">1766</span><br><span class="line">1767</span><br><span class="line">1768</span><br><span class="line">1769</span><br><span class="line">1770</span><br><span class="line">1771</span><br><span class="line">1772</span><br><span class="line">1773</span><br><span class="line">1774</span><br><span class="line">1775</span><br><span class="line">1776</span><br><span class="line">1777</span><br><span class="line">1778</span><br><span class="line">1779</span><br><span class="line">1780</span><br><span class="line">1781</span><br><span class="line">1782</span><br><span class="line">1783</span><br><span class="line">1784</span><br><span class="line">1785</span><br><span class="line">1786</span><br><span class="line">1787</span><br><span class="line">1788</span><br><span class="line">1789</span><br><span class="line">1790</span><br><span class="line">1791</span><br><span class="line">1792</span><br><span class="line">1793</span><br><span class="line">1794</span><br><span class="line">1795</span><br><span class="line">1796</span><br><span class="line">1797</span><br><span class="line">1798</span><br><span class="line">1799</span><br><span class="line">1800</span><br><span class="line">1801</span><br><span class="line">1802</span><br><span class="line">1803</span><br><span class="line">1804</span><br><span class="line">1805</span><br><span class="line">1806</span><br><span class="line">1807</span><br><span class="line">1808</span><br><span class="line">1809</span><br><span class="line">1810</span><br><span class="line">1811</span><br><span class="line">1812</span><br><span class="line">1813</span><br><span class="line">1814</span><br><span class="line">1815</span><br><span class="line">1816</span><br><span class="line">1817</span><br><span class="line">1818</span><br><span class="line">1819</span><br><span class="line">1820</span><br><span class="line">1821</span><br><span class="line">1822</span><br><span class="line">1823</span><br><span class="line">1824</span><br><span class="line">1825</span><br><span class="line">1826</span><br><span class="line">1827</span><br><span class="line">1828</span><br><span class="line">1829</span><br><span class="line">1830</span><br><span class="line">1831</span><br><span class="line">1832</span><br><span class="line">1833</span><br><span class="line">1834</span><br><span class="line">1835</span><br><span class="line">1836</span><br><span class="line">1837</span><br><span class="line">1838</span><br><span class="line">1839</span><br><span class="line">1840</span><br><span class="line">1841</span><br><span class="line">1842</span><br><span class="line">1843</span><br><span class="line">1844</span><br><span class="line">1845</span><br><span class="line">1846</span><br><span class="line">1847</span><br><span class="line">1848</span><br><span class="line">1849</span><br><span class="line">1850</span><br><span class="line">1851</span><br><span class="line">1852</span><br><span class="line">1853</span><br><span class="line">1854</span><br><span class="line">1855</span><br><span class="line">1856</span><br><span class="line">1857</span><br><span class="line">1858</span><br><span class="line">1859</span><br><span class="line">1860</span><br><span class="line">1861</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> <span class="hljs-title class_">Vue</span> <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vue&#x27;</span>;<br><br><span class="hljs-keyword">const</span> _toString = <span class="hljs-title class_">Object</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">toString</span>;<br><span class="hljs-keyword">const</span> hasOwnProperty = <span class="hljs-title class_">Object</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">hasOwnProperty</span>;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">isFn</span> (fn) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">typeof</span> fn === <span class="hljs-string">&#x27;function&#x27;</span><br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">isStr</span> (str) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">typeof</span> str === <span class="hljs-string">&#x27;string&#x27;</span><br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">isPlainObject</span> (obj) &#123;<br>  <span class="hljs-keyword">return</span> _toString.<span class="hljs-title function_">call</span>(obj) === <span class="hljs-string">&#x27;[object Object]&#x27;</span><br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">hasOwn</span> (obj, key) &#123;<br>  <span class="hljs-keyword">return</span> hasOwnProperty.<span class="hljs-title function_">call</span>(obj, key)<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">noop</span> () &#123;&#125;<br><br><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * Create a cached version of a pure function.</span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">cached</span> (fn) &#123;<br>  <span class="hljs-keyword">const</span> cache = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">create</span>(<span class="hljs-literal">null</span>);<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">cachedFn</span> (str) &#123;<br>    <span class="hljs-keyword">const</span> hit = cache[str];<br>    <span class="hljs-keyword">return</span> hit || (cache[str] = <span class="hljs-title function_">fn</span>(str))<br>  &#125;<br>&#125;<br><br><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * Camelize a hyphen-delimited string.</span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">const</span> camelizeRE = <span class="hljs-regexp">/-(\w)/g</span>;<br><span class="hljs-keyword">const</span> camelize = <span class="hljs-title function_">cached</span>(<span class="hljs-function">(<span class="hljs-params">str</span>) =&gt;</span> &#123;<br>  <span class="hljs-keyword">return</span> str.<span class="hljs-title function_">replace</span>(camelizeRE, <span class="hljs-function">(<span class="hljs-params">_, c</span>) =&gt;</span> c ? c.<span class="hljs-title function_">toUpperCase</span>() : <span class="hljs-string">&#x27;&#x27;</span>)<br>&#125;);<br><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">HOOKS</span> = [<br>  <span class="hljs-string">&#x27;invoke&#x27;</span>,<br>  <span class="hljs-string">&#x27;success&#x27;</span>,<br>  <span class="hljs-string">&#x27;fail&#x27;</span>,<br>  <span class="hljs-string">&#x27;complete&#x27;</span>,<br>  <span class="hljs-string">&#x27;returnValue&#x27;</span><br>];<br><br><span class="hljs-keyword">const</span> globalInterceptors = &#123;&#125;;<br><span class="hljs-keyword">const</span> scopedInterceptors = &#123;&#125;;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">mergeHook</span> (parentVal, childVal) &#123;<br>  <span class="hljs-keyword">const</span> res = childVal<br>    ? parentVal<br>      ? parentVal.<span class="hljs-title function_">concat</span>(childVal)<br>      : <span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(childVal)<br>        ? childVal : [childVal]<br>    : parentVal;<br>  <span class="hljs-keyword">return</span> res<br>    ? <span class="hljs-title function_">dedupeHooks</span>(res)<br>    : res<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">dedupeHooks</span> (hooks) &#123;<br>  <span class="hljs-keyword">const</span> res = [];<br>  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; hooks.<span class="hljs-property">length</span>; i++) &#123;<br>    <span class="hljs-keyword">if</span> (res.<span class="hljs-title function_">indexOf</span>(hooks[i]) === -<span class="hljs-number">1</span>) &#123;<br>      res.<span class="hljs-title function_">push</span>(hooks[i]);<br>    &#125;<br>  &#125;<br>  <span class="hljs-keyword">return</span> res<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">removeHook</span> (hooks, hook) &#123;<br>  <span class="hljs-keyword">const</span> index = hooks.<span class="hljs-title function_">indexOf</span>(hook);<br>  <span class="hljs-keyword">if</span> (index !== -<span class="hljs-number">1</span>) &#123;<br>    hooks.<span class="hljs-title function_">splice</span>(index, <span class="hljs-number">1</span>);<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">mergeInterceptorHook</span> (interceptor, option) &#123;<br>  <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(option).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">hook</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-variable constant_">HOOKS</span>.<span class="hljs-title function_">indexOf</span>(hook) !== -<span class="hljs-number">1</span> &amp;&amp; <span class="hljs-title function_">isFn</span>(option[hook])) &#123;<br>      interceptor[hook] = <span class="hljs-title function_">mergeHook</span>(interceptor[hook], option[hook]);<br>    &#125;<br>  &#125;);<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">removeInterceptorHook</span> (interceptor, option) &#123;<br>  <span class="hljs-keyword">if</span> (!interceptor || !option) &#123;<br>    <span class="hljs-keyword">return</span><br>  &#125;<br>  <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(option).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">hook</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-variable constant_">HOOKS</span>.<span class="hljs-title function_">indexOf</span>(hook) !== -<span class="hljs-number">1</span> &amp;&amp; <span class="hljs-title function_">isFn</span>(option[hook])) &#123;<br>      <span class="hljs-title function_">removeHook</span>(interceptor[hook], option[hook]);<br>    &#125;<br>  &#125;);<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">addInterceptor</span> (method, option) &#123;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> method === <span class="hljs-string">&#x27;string&#x27;</span> &amp;&amp; <span class="hljs-title function_">isPlainObject</span>(option)) &#123;<br>    <span class="hljs-title function_">mergeInterceptorHook</span>(scopedInterceptors[method] || (scopedInterceptors[method] = &#123;&#125;), option);<br>  &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPlainObject</span>(method)) &#123;<br>    <span class="hljs-title function_">mergeInterceptorHook</span>(globalInterceptors, method);<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">removeInterceptor</span> (method, option) &#123;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> method === <span class="hljs-string">&#x27;string&#x27;</span>) &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPlainObject</span>(option)) &#123;<br>      <span class="hljs-title function_">removeInterceptorHook</span>(scopedInterceptors[method], option);<br>    &#125; <span class="hljs-keyword">else</span> &#123;<br>      <span class="hljs-keyword">delete</span> scopedInterceptors[method];<br>    &#125;<br>  &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPlainObject</span>(method)) &#123;<br>    <span class="hljs-title function_">removeInterceptorHook</span>(globalInterceptors, method);<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">wrapperHook</span> (hook) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">function</span> (<span class="hljs-params">data</span>) &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-title function_">hook</span>(data) || data<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">isPromise</span> (obj) &#123;<br>  <span class="hljs-keyword">return</span> !!obj &amp;&amp; (<span class="hljs-keyword">typeof</span> obj === <span class="hljs-string">&#x27;object&#x27;</span> || <span class="hljs-keyword">typeof</span> obj === <span class="hljs-string">&#x27;function&#x27;</span>) &amp;&amp; <span class="hljs-keyword">typeof</span> obj.<span class="hljs-property">then</span> === <span class="hljs-string">&#x27;function&#x27;</span><br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">queue</span> (hooks, data) &#123;<br>  <span class="hljs-keyword">let</span> promise = <span class="hljs-literal">false</span>;<br>  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; hooks.<span class="hljs-property">length</span>; i++) &#123;<br>    <span class="hljs-keyword">const</span> hook = hooks[i];<br>    <span class="hljs-keyword">if</span> (promise) &#123;<br>      promise = <span class="hljs-title class_">Promise</span>.<span class="hljs-title function_">resolve</span>(<span class="hljs-title function_">wrapperHook</span>(hook));<br>    &#125; <span class="hljs-keyword">else</span> &#123;<br>      <span class="hljs-keyword">const</span> res = <span class="hljs-title function_">hook</span>(data);<br>      <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPromise</span>(res)) &#123;<br>        promise = <span class="hljs-title class_">Promise</span>.<span class="hljs-title function_">resolve</span>(res);<br>      &#125;<br>      <span class="hljs-keyword">if</span> (res === <span class="hljs-literal">false</span>) &#123;<br>        <span class="hljs-keyword">return</span> &#123;<br>          then () &#123;&#125;<br>        &#125;<br>      &#125;<br>    &#125;<br>  &#125;<br>  <span class="hljs-keyword">return</span> promise || &#123;<br>    then (callback) &#123;<br>      <span class="hljs-keyword">return</span> <span class="hljs-title function_">callback</span>(data)<br>    &#125;<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">wrapperOptions</span> (interceptor, options = &#123;&#125;) &#123;<br>  [<span class="hljs-string">&#x27;success&#x27;</span>, <span class="hljs-string">&#x27;fail&#x27;</span>, <span class="hljs-string">&#x27;complete&#x27;</span>].<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(interceptor[name])) &#123;<br>      <span class="hljs-keyword">const</span> oldCallback = options[name];<br>      options[name] = <span class="hljs-keyword">function</span> <span class="hljs-title function_">callbackInterceptor</span> (res) &#123;<br>        <span class="hljs-title function_">queue</span>(interceptor[name], res).<span class="hljs-title function_">then</span>(<span class="hljs-function">(<span class="hljs-params">res</span>) =&gt;</span> &#123;<br>          <span class="hljs-comment">/* eslint-disable no-mixed-operators */</span><br>          <span class="hljs-keyword">return</span> <span class="hljs-title function_">isFn</span>(oldCallback) &amp;&amp; <span class="hljs-title function_">oldCallback</span>(res) || res<br>        &#125;);<br>      &#125;;<br>    &#125;<br>  &#125;);<br>  <span class="hljs-keyword">return</span> options<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">wrapperReturnValue</span> (method, returnValue) &#123;<br>  <span class="hljs-keyword">const</span> returnValueHooks = [];<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(globalInterceptors.<span class="hljs-property">returnValue</span>)) &#123;<br>    returnValueHooks.<span class="hljs-title function_">push</span>(...globalInterceptors.<span class="hljs-property">returnValue</span>);<br>  &#125;<br>  <span class="hljs-keyword">const</span> interceptor = scopedInterceptors[method];<br>  <span class="hljs-keyword">if</span> (interceptor &amp;&amp; <span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(interceptor.<span class="hljs-property">returnValue</span>)) &#123;<br>    returnValueHooks.<span class="hljs-title function_">push</span>(...interceptor.<span class="hljs-property">returnValue</span>);<br>  &#125;<br>  returnValueHooks.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">hook</span> =&gt;</span> &#123;<br>    returnValue = <span class="hljs-title function_">hook</span>(returnValue) || returnValue;<br>  &#125;);<br>  <span class="hljs-keyword">return</span> returnValue<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">getApiInterceptorHooks</span> (method) &#123;<br>  <span class="hljs-keyword">const</span> interceptor = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">create</span>(<span class="hljs-literal">null</span>);<br>  <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(globalInterceptors).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">hook</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">if</span> (hook !== <span class="hljs-string">&#x27;returnValue&#x27;</span>) &#123;<br>      interceptor[hook] = globalInterceptors[hook].<span class="hljs-title function_">slice</span>();<br>    &#125;<br>  &#125;);<br>  <span class="hljs-keyword">const</span> scopedInterceptor = scopedInterceptors[method];<br>  <span class="hljs-keyword">if</span> (scopedInterceptor) &#123;<br>    <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(scopedInterceptor).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">hook</span> =&gt;</span> &#123;<br>      <span class="hljs-keyword">if</span> (hook !== <span class="hljs-string">&#x27;returnValue&#x27;</span>) &#123;<br>        interceptor[hook] = (interceptor[hook] || []).<span class="hljs-title function_">concat</span>(scopedInterceptor[hook]);<br>      &#125;<br>    &#125;);<br>  &#125;<br>  <span class="hljs-keyword">return</span> interceptor<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">invokeApi</span> (method, api, options, ...params) &#123;<br>  <span class="hljs-keyword">const</span> interceptor = <span class="hljs-title function_">getApiInterceptorHooks</span>(method);<br>  <span class="hljs-keyword">if</span> (interceptor &amp;&amp; <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(interceptor).<span class="hljs-property">length</span>) &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(interceptor.<span class="hljs-property">invoke</span>)) &#123;<br>      <span class="hljs-keyword">const</span> res = <span class="hljs-title function_">queue</span>(interceptor.<span class="hljs-property">invoke</span>, options);<br>      <span class="hljs-keyword">return</span> res.<span class="hljs-title function_">then</span>(<span class="hljs-function">(<span class="hljs-params">options</span>) =&gt;</span> &#123;<br>        <span class="hljs-keyword">return</span> <span class="hljs-title function_">api</span>(<span class="hljs-title function_">wrapperOptions</span>(interceptor, options), ...params)<br>      &#125;)<br>    &#125; <span class="hljs-keyword">else</span> &#123;<br>      <span class="hljs-keyword">return</span> <span class="hljs-title function_">api</span>(<span class="hljs-title function_">wrapperOptions</span>(interceptor, options), ...params)<br>    &#125;<br>  &#125;<br>  <span class="hljs-keyword">return</span> <span class="hljs-title function_">api</span>(options, ...params)<br>&#125;<br><br><span class="hljs-keyword">const</span> promiseInterceptor = &#123;<br>  returnValue (res) &#123;<br>    <span class="hljs-keyword">if</span> (!<span class="hljs-title function_">isPromise</span>(res)) &#123;<br>      <span class="hljs-keyword">return</span> res<br>    &#125;<br>    <span class="hljs-keyword">return</span> res.<span class="hljs-title function_">then</span>(<span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;<br>      <span class="hljs-keyword">return</span> res[<span class="hljs-number">1</span>]<br>    &#125;).<span class="hljs-title function_">catch</span>(<span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;<br>      <span class="hljs-keyword">return</span> res[<span class="hljs-number">0</span>]<br>    &#125;)<br>  &#125;<br>&#125;;<br><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">SYNC_API_RE</span> =<br>  <span class="hljs-regexp">/^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/</span>;<br><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">CONTEXT_API_RE</span> = <span class="hljs-regexp">/^create|Manager$/</span>;<br><br><span class="hljs-comment">// Context例外情况</span><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">CONTEXT_API_RE_EXC</span> = [<span class="hljs-string">&#x27;createBLEConnection&#x27;</span>];<br><br><span class="hljs-comment">// 同步例外情况</span><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">ASYNC_API</span> = [<span class="hljs-string">&#x27;createBLEConnection&#x27;</span>];<br><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">CALLBACK_API_RE</span> = <span class="hljs-regexp">/^on|^off/</span>;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">isContextApi</span> (name) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-variable constant_">CONTEXT_API_RE</span>.<span class="hljs-title function_">test</span>(name) &amp;&amp; <span class="hljs-variable constant_">CONTEXT_API_RE_EXC</span>.<span class="hljs-title function_">indexOf</span>(name) === -<span class="hljs-number">1</span><br>&#125;<br><span class="hljs-keyword">function</span> <span class="hljs-title function_">isSyncApi</span> (name) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-variable constant_">SYNC_API_RE</span>.<span class="hljs-title function_">test</span>(name) &amp;&amp; <span class="hljs-variable constant_">ASYNC_API</span>.<span class="hljs-title function_">indexOf</span>(name) === -<span class="hljs-number">1</span><br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">isCallbackApi</span> (name) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-variable constant_">CALLBACK_API_RE</span>.<span class="hljs-title function_">test</span>(name) &amp;&amp; name !== <span class="hljs-string">&#x27;onPush&#x27;</span><br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">handlePromise</span> (promise) &#123;<br>  <span class="hljs-keyword">return</span> promise.<span class="hljs-title function_">then</span>(<span class="hljs-function"><span class="hljs-params">data</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">return</span> [<span class="hljs-literal">null</span>, data]<br>  &#125;)<br>    .<span class="hljs-title function_">catch</span>(<span class="hljs-function"><span class="hljs-params">err</span> =&gt;</span> [err])<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">shouldPromise</span> (name) &#123;<br>  <span class="hljs-keyword">if</span> (<br>    <span class="hljs-title function_">isContextApi</span>(name) ||<br>    <span class="hljs-title function_">isSyncApi</span>(name) ||<br>    <span class="hljs-title function_">isCallbackApi</span>(name)<br>  ) &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span><br>  &#125;<br>  <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span><br>&#125;<br><br><span class="hljs-comment">/* eslint-disable no-extend-native */</span><br><span class="hljs-keyword">if</span> (!<span class="hljs-title class_">Promise</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">finally</span>) &#123;<br>  <span class="hljs-title class_">Promise</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">finally</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">callback</span>) &#123;<br>    <span class="hljs-keyword">const</span> promise = <span class="hljs-variable language_">this</span>.<span class="hljs-property">constructor</span>;<br>    <span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">then</span>(<br>      <span class="hljs-function"><span class="hljs-params">value</span> =&gt;</span> promise.<span class="hljs-title function_">resolve</span>(<span class="hljs-title function_">callback</span>()).<span class="hljs-title function_">then</span>(<span class="hljs-function">() =&gt;</span> value),<br>      <span class="hljs-function"><span class="hljs-params">reason</span> =&gt;</span> promise.<span class="hljs-title function_">resolve</span>(<span class="hljs-title function_">callback</span>()).<span class="hljs-title function_">then</span>(<span class="hljs-function">() =&gt;</span> &#123;<br>        <span class="hljs-keyword">throw</span> reason<br>      &#125;)<br>    )<br>  &#125;;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">promisify</span> (name, api) &#123;<br>  <span class="hljs-keyword">if</span> (!<span class="hljs-title function_">shouldPromise</span>(name)) &#123;<br>    <span class="hljs-keyword">return</span> api<br>  &#125;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">promiseApi</span> (options = &#123;&#125;, ...params) &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(options.<span class="hljs-property">success</span>) || <span class="hljs-title function_">isFn</span>(options.<span class="hljs-property">fail</span>) || <span class="hljs-title function_">isFn</span>(options.<span class="hljs-property">complete</span>)) &#123;<br>      <span class="hljs-keyword">return</span> <span class="hljs-title function_">wrapperReturnValue</span>(name, <span class="hljs-title function_">invokeApi</span>(name, api, options, ...params))<br>    &#125;<br>    <span class="hljs-keyword">return</span> <span class="hljs-title function_">wrapperReturnValue</span>(name, <span class="hljs-title function_">handlePromise</span>(<span class="hljs-keyword">new</span> <span class="hljs-title class_">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> &#123;<br>      <span class="hljs-title function_">invokeApi</span>(name, api, <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">assign</span>(&#123;&#125;, options, &#123;<br>        <span class="hljs-attr">success</span>: resolve,<br>        <span class="hljs-attr">fail</span>: reject<br>      &#125;), ...params);<br>    &#125;)))<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">EPS</span> = <span class="hljs-number">1e-4</span>;<br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">BASE_DEVICE_WIDTH</span> = <span class="hljs-number">750</span>;<br><span class="hljs-keyword">let</span> isIOS = <span class="hljs-literal">false</span>;<br><span class="hljs-keyword">let</span> deviceWidth = <span class="hljs-number">0</span>;<br><span class="hljs-keyword">let</span> deviceDPR = <span class="hljs-number">0</span>;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">checkDeviceWidth</span> () &#123;<br>  <span class="hljs-keyword">const</span> &#123;<br>    platform,<br>    pixelRatio,<br>    windowWidth<br>  &#125; = wx.<span class="hljs-title function_">getSystemInfoSync</span>(); <span class="hljs-comment">// uni=&gt;wx runtime 编译目标是 uni 对象，内部不允许直接使用 uni</span><br><br>  deviceWidth = windowWidth;<br>  deviceDPR = pixelRatio;<br>  isIOS = platform === <span class="hljs-string">&#x27;ios&#x27;</span>;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">upx2px</span> (number, newDeviceWidth) &#123;<br>  <span class="hljs-keyword">if</span> (deviceWidth === <span class="hljs-number">0</span>) &#123;<br>    <span class="hljs-title function_">checkDeviceWidth</span>();<br>  &#125;<br><br>  number = <span class="hljs-title class_">Number</span>(number);<br>  <span class="hljs-keyword">if</span> (number === <span class="hljs-number">0</span>) &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span><br>  &#125;<br>  <span class="hljs-keyword">let</span> result = (number / <span class="hljs-variable constant_">BASE_DEVICE_WIDTH</span>) * (newDeviceWidth || deviceWidth);<br>  <span class="hljs-keyword">if</span> (result &lt; <span class="hljs-number">0</span>) &#123;<br>    result = -result;<br>  &#125;<br>  result = <span class="hljs-title class_">Math</span>.<span class="hljs-title function_">floor</span>(result + <span class="hljs-variable constant_">EPS</span>);<br>  <span class="hljs-keyword">if</span> (result === <span class="hljs-number">0</span>) &#123;<br>    <span class="hljs-keyword">if</span> (deviceDPR === <span class="hljs-number">1</span> || !isIOS) &#123;<br>      result = <span class="hljs-number">1</span>;<br>    &#125; <span class="hljs-keyword">else</span> &#123;<br>      result = <span class="hljs-number">0.5</span>;<br>    &#125;<br>  &#125;<br>  <span class="hljs-keyword">return</span> number &lt; <span class="hljs-number">0</span> ? -result : result<br>&#125;<br><br><span class="hljs-keyword">const</span> interceptors = &#123;<br>  promiseInterceptor<br>&#125;;<br><br><span class="hljs-keyword">var</span> baseApi = <span class="hljs-comment">/*#__PURE__*/</span><span class="hljs-title class_">Object</span>.<span class="hljs-title function_">freeze</span>(&#123;<br>  <span class="hljs-attr">__proto__</span>: <span class="hljs-literal">null</span>,<br>  <span class="hljs-attr">upx2px</span>: upx2px,<br>  <span class="hljs-attr">addInterceptor</span>: addInterceptor,<br>  <span class="hljs-attr">removeInterceptor</span>: removeInterceptor,<br>  <span class="hljs-attr">interceptors</span>: interceptors<br>&#125;);<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">findExistsPageIndex</span> (url) &#123;<br>  <span class="hljs-keyword">const</span> pages = <span class="hljs-title function_">getCurrentPages</span>();<br>  <span class="hljs-keyword">let</span> len = pages.<span class="hljs-property">length</span>;<br>  <span class="hljs-keyword">while</span> (len--) &#123;<br>    <span class="hljs-keyword">const</span> page = pages[len];<br>    <span class="hljs-keyword">if</span> (page.<span class="hljs-property">$page</span> &amp;&amp; page.<span class="hljs-property">$page</span>.<span class="hljs-property">fullPath</span> === url) &#123;<br>      <span class="hljs-keyword">return</span> len<br>    &#125;<br>  &#125;<br>  <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span><br>&#125;<br><br><span class="hljs-keyword">var</span> redirectTo = &#123;<br>  name (fromArgs) &#123;<br>    <span class="hljs-keyword">if</span> (fromArgs.<span class="hljs-property">exists</span> === <span class="hljs-string">&#x27;back&#x27;</span> &amp;&amp; fromArgs.<span class="hljs-property">delta</span>) &#123;<br>      <span class="hljs-keyword">return</span> <span class="hljs-string">&#x27;navigateBack&#x27;</span><br>    &#125;<br>    <span class="hljs-keyword">return</span> <span class="hljs-string">&#x27;redirectTo&#x27;</span><br>  &#125;,<br>  args (fromArgs) &#123;<br>    <span class="hljs-keyword">if</span> (fromArgs.<span class="hljs-property">exists</span> === <span class="hljs-string">&#x27;back&#x27;</span> &amp;&amp; fromArgs.<span class="hljs-property">url</span>) &#123;<br>      <span class="hljs-keyword">const</span> existsPageIndex = <span class="hljs-title function_">findExistsPageIndex</span>(fromArgs.<span class="hljs-property">url</span>);<br>      <span class="hljs-keyword">if</span> (existsPageIndex !== -<span class="hljs-number">1</span>) &#123;<br>        <span class="hljs-keyword">const</span> delta = <span class="hljs-title function_">getCurrentPages</span>().<span class="hljs-property">length</span> - <span class="hljs-number">1</span> - existsPageIndex;<br>        <span class="hljs-keyword">if</span> (delta &gt; <span class="hljs-number">0</span>) &#123;<br>          fromArgs.<span class="hljs-property">delta</span> = delta;<br>        &#125;<br>      &#125;<br>    &#125;<br>  &#125;<br>&#125;;<br><br><span class="hljs-keyword">var</span> previewImage = &#123;<br>  args (fromArgs) &#123;<br>    <span class="hljs-keyword">let</span> currentIndex = <span class="hljs-built_in">parseInt</span>(fromArgs.<span class="hljs-property">current</span>);<br>    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">isNaN</span>(currentIndex)) &#123;<br>      <span class="hljs-keyword">return</span><br>    &#125;<br>    <span class="hljs-keyword">const</span> urls = fromArgs.<span class="hljs-property">urls</span>;<br>    <span class="hljs-keyword">if</span> (!<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(urls)) &#123;<br>      <span class="hljs-keyword">return</span><br>    &#125;<br>    <span class="hljs-keyword">const</span> len = urls.<span class="hljs-property">length</span>;<br>    <span class="hljs-keyword">if</span> (!len) &#123;<br>      <span class="hljs-keyword">return</span><br>    &#125;<br>    <span class="hljs-keyword">if</span> (currentIndex &lt; <span class="hljs-number">0</span>) &#123;<br>      currentIndex = <span class="hljs-number">0</span>;<br>    &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (currentIndex &gt;= len) &#123;<br>      currentIndex = len - <span class="hljs-number">1</span>;<br>    &#125;<br>    <span class="hljs-keyword">if</span> (currentIndex &gt; <span class="hljs-number">0</span>) &#123;<br>      fromArgs.<span class="hljs-property">current</span> = urls[currentIndex];<br>      fromArgs.<span class="hljs-property">urls</span> = urls.<span class="hljs-title function_">filter</span>(<br>        <span class="hljs-function">(<span class="hljs-params">item, index</span>) =&gt;</span> index &lt; currentIndex ? item !== urls[currentIndex] : <span class="hljs-literal">true</span><br>      );<br>    &#125; <span class="hljs-keyword">else</span> &#123;<br>      fromArgs.<span class="hljs-property">current</span> = urls[<span class="hljs-number">0</span>];<br>    &#125;<br>    <span class="hljs-keyword">return</span> &#123;<br>      <span class="hljs-attr">indicator</span>: <span class="hljs-literal">false</span>,<br>      <span class="hljs-attr">loop</span>: <span class="hljs-literal">false</span><br>    &#125;<br>  &#125;<br>&#125;;<br><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">UUID_KEY</span> = <span class="hljs-string">&#x27;__DC_STAT_UUID&#x27;</span>;<br><span class="hljs-keyword">let</span> deviceId;<br><span class="hljs-keyword">function</span> <span class="hljs-title function_">addUuid</span> (result) &#123;<br>  deviceId = deviceId || wx.<span class="hljs-title function_">getStorageSync</span>(<span class="hljs-variable constant_">UUID_KEY</span>);<br>  <span class="hljs-keyword">if</span> (!deviceId) &#123;<br>    deviceId = <span class="hljs-title class_">Date</span>.<span class="hljs-title function_">now</span>() + <span class="hljs-string">&#x27;&#x27;</span> + <span class="hljs-title class_">Math</span>.<span class="hljs-title function_">floor</span>(<span class="hljs-title class_">Math</span>.<span class="hljs-title function_">random</span>() * <span class="hljs-number">1e7</span>);<br>    wx.<span class="hljs-title function_">setStorage</span>(&#123;<br>      <span class="hljs-attr">key</span>: <span class="hljs-variable constant_">UUID_KEY</span>,<br>      <span class="hljs-attr">data</span>: deviceId<br>    &#125;);<br>  &#125;<br>  result.<span class="hljs-property">deviceId</span> = deviceId;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">addSafeAreaInsets</span> (result) &#123;<br>  <span class="hljs-keyword">if</span> (result.<span class="hljs-property">safeArea</span>) &#123;<br>    <span class="hljs-keyword">const</span> safeArea = result.<span class="hljs-property">safeArea</span>;<br>    result.<span class="hljs-property">safeAreaInsets</span> = &#123;<br>      <span class="hljs-attr">top</span>: safeArea.<span class="hljs-property">top</span>,<br>      <span class="hljs-attr">left</span>: safeArea.<span class="hljs-property">left</span>,<br>      <span class="hljs-attr">right</span>: result.<span class="hljs-property">windowWidth</span> - safeArea.<span class="hljs-property">right</span>,<br>      <span class="hljs-attr">bottom</span>: result.<span class="hljs-property">windowHeight</span> - safeArea.<span class="hljs-property">bottom</span><br>    &#125;;<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">var</span> getSystemInfo = &#123;<br>  <span class="hljs-attr">returnValue</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">result</span>) &#123;<br>    <span class="hljs-title function_">addUuid</span>(result);<br>    <span class="hljs-title function_">addSafeAreaInsets</span>(result);<br>  &#125;<br>&#125;;<br><br><span class="hljs-comment">// import navigateTo from &#x27;uni-helpers/navigate-to&#x27;</span><br><br><span class="hljs-keyword">const</span> protocols = &#123;<br>  redirectTo,<br>  <span class="hljs-comment">// navigateTo,  // 由于在微信开发者工具的页面参数，会显示__id__参数，因此暂时关闭mp-weixin对于navigateTo的AOP</span><br>  previewImage,<br>  getSystemInfo,<br>  <span class="hljs-attr">getSystemInfoSync</span>: getSystemInfo<br>&#125;;<br><span class="hljs-keyword">const</span> todos = [<br>  <span class="hljs-string">&#x27;vibrate&#x27;</span>,<br>  <span class="hljs-string">&#x27;preloadPage&#x27;</span>,<br>  <span class="hljs-string">&#x27;unPreloadPage&#x27;</span>,<br>  <span class="hljs-string">&#x27;loadSubPackage&#x27;</span><br>];<br><span class="hljs-keyword">const</span> canIUses = [];<br><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">CALLBACKS</span> = [<span class="hljs-string">&#x27;success&#x27;</span>, <span class="hljs-string">&#x27;fail&#x27;</span>, <span class="hljs-string">&#x27;cancel&#x27;</span>, <span class="hljs-string">&#x27;complete&#x27;</span>];<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">processCallback</span> (methodName, method, returnValue) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">function</span> (<span class="hljs-params">res</span>) &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-title function_">method</span>(<span class="hljs-title function_">processReturnValue</span>(methodName, res, returnValue))<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">processArgs</span> (methodName, fromArgs, argsOption = &#123;&#125;, returnValue = &#123;&#125;, keepFromArgs = <span class="hljs-literal">false</span>) &#123;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPlainObject</span>(fromArgs)) &#123; <span class="hljs-comment">// 一般 api 的参数解析</span><br>    <span class="hljs-keyword">const</span> toArgs = keepFromArgs === <span class="hljs-literal">true</span> ? fromArgs : &#123;&#125;; <span class="hljs-comment">// returnValue 为 false 时，说明是格式化返回值，直接在返回值对象上修改赋值</span><br>    <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(argsOption)) &#123;<br>      argsOption = <span class="hljs-title function_">argsOption</span>(fromArgs, toArgs) || &#123;&#125;;<br>    &#125;<br>    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> key <span class="hljs-keyword">in</span> fromArgs) &#123;<br>      <span class="hljs-keyword">if</span> (<span class="hljs-title function_">hasOwn</span>(argsOption, key)) &#123;<br>        <span class="hljs-keyword">let</span> keyOption = argsOption[key];<br>        <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(keyOption)) &#123;<br>          keyOption = <span class="hljs-title function_">keyOption</span>(fromArgs[key], fromArgs, toArgs);<br>        &#125;<br>        <span class="hljs-keyword">if</span> (!keyOption) &#123; <span class="hljs-comment">// 不支持的参数</span><br>          <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">warn</span>(<span class="hljs-string">`The &#x27;<span class="hljs-subst">$&#123;methodName&#125;</span>&#x27; method of platform &#x27;微信小程序&#x27; does not support option &#x27;<span class="hljs-subst">$&#123;key&#125;</span>&#x27;`</span>);<br>        &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isStr</span>(keyOption)) &#123; <span class="hljs-comment">// 重写参数 key</span><br>          toArgs[keyOption] = fromArgs[key];<br>        &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPlainObject</span>(keyOption)) &#123; <span class="hljs-comment">// &#123;name:newName,value:value&#125;可重新指定参数 key:value</span><br>          toArgs[keyOption.<span class="hljs-property">name</span> ? keyOption.<span class="hljs-property">name</span> : key] = keyOption.<span class="hljs-property">value</span>;<br>        &#125;<br>      &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-variable constant_">CALLBACKS</span>.<span class="hljs-title function_">indexOf</span>(key) !== -<span class="hljs-number">1</span>) &#123;<br>        <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(fromArgs[key])) &#123;<br>          toArgs[key] = <span class="hljs-title function_">processCallback</span>(methodName, fromArgs[key], returnValue);<br>        &#125;<br>      &#125; <span class="hljs-keyword">else</span> &#123;<br>        <span class="hljs-keyword">if</span> (!keepFromArgs) &#123;<br>          toArgs[key] = fromArgs[key];<br>        &#125;<br>      &#125;<br>    &#125;<br>    <span class="hljs-keyword">return</span> toArgs<br>  &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(fromArgs)) &#123;<br>    fromArgs = <span class="hljs-title function_">processCallback</span>(methodName, fromArgs, returnValue);<br>  &#125;<br>  <span class="hljs-keyword">return</span> fromArgs<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">processReturnValue</span> (methodName, res, returnValue, keepReturnValue = <span class="hljs-literal">false</span>) &#123;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(protocols.<span class="hljs-property">returnValue</span>)) &#123; <span class="hljs-comment">// 处理通用 returnValue</span><br>    res = protocols.<span class="hljs-title function_">returnValue</span>(methodName, res);<br>  &#125;<br>  <span class="hljs-keyword">return</span> <span class="hljs-title function_">processArgs</span>(methodName, res, returnValue, &#123;&#125;, keepReturnValue)<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">wrapper</span> (methodName, method) &#123;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">hasOwn</span>(protocols, methodName)) &#123;<br>    <span class="hljs-keyword">const</span> protocol = protocols[methodName];<br>    <span class="hljs-keyword">if</span> (!protocol) &#123; <span class="hljs-comment">// 暂不支持的 api</span><br>      <span class="hljs-keyword">return</span> <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) &#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">`Platform &#x27;微信小程序&#x27; does not support &#x27;<span class="hljs-subst">$&#123;methodName&#125;</span>&#x27;.`</span>);<br>      &#125;<br>    &#125;<br>    <span class="hljs-keyword">return</span> <span class="hljs-keyword">function</span> (<span class="hljs-params">arg1, arg2</span>) &#123; <span class="hljs-comment">// 目前 api 最多两个参数</span><br>      <span class="hljs-keyword">let</span> options = protocol;<br>      <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(protocol)) &#123;<br>        options = <span class="hljs-title function_">protocol</span>(arg1);<br>      &#125;<br><br>      arg1 = <span class="hljs-title function_">processArgs</span>(methodName, arg1, options.<span class="hljs-property">args</span>, options.<span class="hljs-property">returnValue</span>);<br><br>      <span class="hljs-keyword">const</span> args = [arg1];<br>      <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> arg2 !== <span class="hljs-string">&#x27;undefined&#x27;</span>) &#123;<br>        args.<span class="hljs-title function_">push</span>(arg2);<br>      &#125;<br>      <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(options.<span class="hljs-property">name</span>)) &#123;<br>        methodName = options.<span class="hljs-title function_">name</span>(arg1);<br>      &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isStr</span>(options.<span class="hljs-property">name</span>)) &#123;<br>        methodName = options.<span class="hljs-property">name</span>;<br>      &#125;<br>      <span class="hljs-keyword">const</span> returnValue = wx[methodName].<span class="hljs-title function_">apply</span>(wx, args);<br>      <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isSyncApi</span>(methodName)) &#123; <span class="hljs-comment">// 同步 api</span><br>        <span class="hljs-keyword">return</span> <span class="hljs-title function_">processReturnValue</span>(methodName, returnValue, options.<span class="hljs-property">returnValue</span>, <span class="hljs-title function_">isContextApi</span>(methodName))<br>      &#125;<br>      <span class="hljs-keyword">return</span> returnValue<br>    &#125;<br>  &#125;<br>  <span class="hljs-keyword">return</span> method<br>&#125;<br><br><span class="hljs-keyword">const</span> todoApis = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">create</span>(<span class="hljs-literal">null</span>);<br><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">TODOS</span> = [<br>  <span class="hljs-string">&#x27;onTabBarMidButtonTap&#x27;</span>,<br>  <span class="hljs-string">&#x27;subscribePush&#x27;</span>,<br>  <span class="hljs-string">&#x27;unsubscribePush&#x27;</span>,<br>  <span class="hljs-string">&#x27;onPush&#x27;</span>,<br>  <span class="hljs-string">&#x27;offPush&#x27;</span>,<br>  <span class="hljs-string">&#x27;share&#x27;</span><br>];<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">createTodoApi</span> (name) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">todoApi</span> (&#123;<br>    fail,<br>    complete<br>  &#125;) &#123;<br>    <span class="hljs-keyword">const</span> res = &#123;<br>      <span class="hljs-attr">errMsg</span>: <span class="hljs-string">`<span class="hljs-subst">$&#123;name&#125;</span>:fail method &#x27;<span class="hljs-subst">$&#123;name&#125;</span>&#x27; not supported`</span><br>    &#125;;<br>    <span class="hljs-title function_">isFn</span>(fail) &amp;&amp; <span class="hljs-title function_">fail</span>(res);<br>    <span class="hljs-title function_">isFn</span>(complete) &amp;&amp; <span class="hljs-title function_">complete</span>(res);<br>  &#125;<br>&#125;<br><br><span class="hljs-variable constant_">TODOS</span>.<span class="hljs-title function_">forEach</span>(<span class="hljs-keyword">function</span> (<span class="hljs-params">name</span>) &#123;<br>  todoApis[name] = <span class="hljs-title function_">createTodoApi</span>(name);<br>&#125;);<br><br><span class="hljs-keyword">var</span> providers = &#123;<br>  <span class="hljs-attr">oauth</span>: [<span class="hljs-string">&#x27;weixin&#x27;</span>],<br>  <span class="hljs-attr">share</span>: [<span class="hljs-string">&#x27;weixin&#x27;</span>],<br>  <span class="hljs-attr">payment</span>: [<span class="hljs-string">&#x27;wxpay&#x27;</span>],<br>  <span class="hljs-attr">push</span>: [<span class="hljs-string">&#x27;weixin&#x27;</span>]<br>&#125;;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">getProvider</span> (&#123;<br>  service,<br>  success,<br>  fail,<br>  complete<br>&#125;) &#123;<br>  <span class="hljs-keyword">let</span> res = <span class="hljs-literal">false</span>;<br>  <span class="hljs-keyword">if</span> (providers[service]) &#123;<br>    res = &#123;<br>      <span class="hljs-attr">errMsg</span>: <span class="hljs-string">&#x27;getProvider:ok&#x27;</span>,<br>      service,<br>      <span class="hljs-attr">provider</span>: providers[service]<br>    &#125;;<br>    <span class="hljs-title function_">isFn</span>(success) &amp;&amp; <span class="hljs-title function_">success</span>(res);<br>  &#125; <span class="hljs-keyword">else</span> &#123;<br>    res = &#123;<br>      <span class="hljs-attr">errMsg</span>: <span class="hljs-string">&#x27;getProvider:fail service not found&#x27;</span><br>    &#125;;<br>    <span class="hljs-title function_">isFn</span>(fail) &amp;&amp; <span class="hljs-title function_">fail</span>(res);<br>  &#125;<br>  <span class="hljs-title function_">isFn</span>(complete) &amp;&amp; <span class="hljs-title function_">complete</span>(res);<br>&#125;<br><br><span class="hljs-keyword">var</span> extraApi = <span class="hljs-comment">/*#__PURE__*/</span><span class="hljs-title class_">Object</span>.<span class="hljs-title function_">freeze</span>(&#123;<br>  <span class="hljs-attr">__proto__</span>: <span class="hljs-literal">null</span>,<br>  <span class="hljs-attr">getProvider</span>: getProvider<br>&#125;);<br><br><span class="hljs-keyword">const</span> getEmitter = (<span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) &#123;<br>  <span class="hljs-keyword">let</span> <span class="hljs-title class_">Emitter</span>;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">getUniEmitter</span> () &#123;<br>    <span class="hljs-keyword">if</span> (!<span class="hljs-title class_">Emitter</span>) &#123;<br>      <span class="hljs-title class_">Emitter</span> = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Vue</span>();<br>    &#125;<br>    <span class="hljs-keyword">return</span> <span class="hljs-title class_">Emitter</span><br>  &#125;<br>&#125;)();<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">apply</span> (ctx, method, args) &#123;<br>  <span class="hljs-keyword">return</span> ctx[method].<span class="hljs-title function_">apply</span>(ctx, args)<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">$on</span> () &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-title function_">apply</span>(<span class="hljs-title function_">getEmitter</span>(), <span class="hljs-string">&#x27;$on&#x27;</span>, [...<span class="hljs-variable language_">arguments</span>])<br>&#125;<br><span class="hljs-keyword">function</span> <span class="hljs-title function_">$off</span> () &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-title function_">apply</span>(<span class="hljs-title function_">getEmitter</span>(), <span class="hljs-string">&#x27;$off&#x27;</span>, [...<span class="hljs-variable language_">arguments</span>])<br>&#125;<br><span class="hljs-keyword">function</span> <span class="hljs-title function_">$once</span> () &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-title function_">apply</span>(<span class="hljs-title function_">getEmitter</span>(), <span class="hljs-string">&#x27;$once&#x27;</span>, [...<span class="hljs-variable language_">arguments</span>])<br>&#125;<br><span class="hljs-keyword">function</span> <span class="hljs-title function_">$emit</span> () &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-title function_">apply</span>(<span class="hljs-title function_">getEmitter</span>(), <span class="hljs-string">&#x27;$emit&#x27;</span>, [...<span class="hljs-variable language_">arguments</span>])<br>&#125;<br><br><span class="hljs-keyword">var</span> eventApi = <span class="hljs-comment">/*#__PURE__*/</span><span class="hljs-title class_">Object</span>.<span class="hljs-title function_">freeze</span>(&#123;<br>  <span class="hljs-attr">__proto__</span>: <span class="hljs-literal">null</span>,<br>  <span class="hljs-attr">$on</span>: $on,<br>  <span class="hljs-attr">$off</span>: $off,<br>  <span class="hljs-attr">$once</span>: $once,<br>  <span class="hljs-attr">$emit</span>: $emit<br>&#125;);<br><br><span class="hljs-keyword">var</span> api = <span class="hljs-comment">/*#__PURE__*/</span><span class="hljs-title class_">Object</span>.<span class="hljs-title function_">freeze</span>(&#123;<br>  <span class="hljs-attr">__proto__</span>: <span class="hljs-literal">null</span><br>&#125;);<br><br><span class="hljs-keyword">const</span> <span class="hljs-title class_">MPPage</span> = <span class="hljs-title class_">Page</span>;<br><span class="hljs-keyword">const</span> <span class="hljs-title class_">MPComponent</span> = <span class="hljs-title class_">Component</span>;<br><br><span class="hljs-keyword">const</span> customizeRE = <span class="hljs-regexp">/:/g</span>;<br><br><span class="hljs-keyword">const</span> customize = <span class="hljs-title function_">cached</span>(<span class="hljs-function">(<span class="hljs-params">str</span>) =&gt;</span> &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-title function_">camelize</span>(str.<span class="hljs-title function_">replace</span>(customizeRE, <span class="hljs-string">&#x27;-&#x27;</span>))<br>&#125;);<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initTriggerEvent</span> (mpInstance) &#123;<br>  &#123;<br>    <span class="hljs-keyword">if</span> (!wx.<span class="hljs-property">canIUse</span> || !wx.<span class="hljs-title function_">canIUse</span>(<span class="hljs-string">&#x27;nextTick&#x27;</span>)) &#123;<br>      <span class="hljs-keyword">return</span><br>    &#125;<br>  &#125;<br>  <span class="hljs-keyword">const</span> oldTriggerEvent = mpInstance.<span class="hljs-property">triggerEvent</span>;<br>  mpInstance.<span class="hljs-property">triggerEvent</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">event, ...args</span>) &#123;<br>    <span class="hljs-keyword">return</span> oldTriggerEvent.<span class="hljs-title function_">apply</span>(mpInstance, [<span class="hljs-title function_">customize</span>(event), ...args])<br>  &#125;;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initHook</span> (name, options) &#123;<br>  <span class="hljs-keyword">const</span> oldHook = options[name];<br>  <span class="hljs-keyword">if</span> (!oldHook) &#123;<br>    options[name] = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) &#123;<br>      <span class="hljs-title function_">initTriggerEvent</span>(<span class="hljs-variable language_">this</span>);<br>    &#125;;<br>  &#125; <span class="hljs-keyword">else</span> &#123;<br>    options[name] = <span class="hljs-keyword">function</span> (<span class="hljs-params">...args</span>) &#123;<br>      <span class="hljs-title function_">initTriggerEvent</span>(<span class="hljs-variable language_">this</span>);<br>      <span class="hljs-keyword">return</span> oldHook.<span class="hljs-title function_">apply</span>(<span class="hljs-variable language_">this</span>, args)<br>    &#125;;<br>  &#125;<br>&#125;<br><span class="hljs-keyword">if</span> (!<span class="hljs-title class_">MPPage</span>.<span class="hljs-property">__$wrappered</span>) &#123;<br>  <span class="hljs-title class_">MPPage</span>.<span class="hljs-property">__$wrappered</span> = <span class="hljs-literal">true</span>;<br>  <span class="hljs-title class_">Page</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">options = &#123;&#125;</span>) &#123;<br>    <span class="hljs-title function_">initHook</span>(<span class="hljs-string">&#x27;onLoad&#x27;</span>, options);<br>    <span class="hljs-keyword">return</span> <span class="hljs-title class_">MPPage</span>(options)<br>  &#125;;<br>  <span class="hljs-title class_">Page</span>.<span class="hljs-property">after</span> = <span class="hljs-title class_">MPPage</span>.<span class="hljs-property">after</span>;<br><br>  <span class="hljs-title class_">Component</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">options = &#123;&#125;</span>) &#123;<br>    <span class="hljs-title function_">initHook</span>(<span class="hljs-string">&#x27;created&#x27;</span>, options);<br>    <span class="hljs-keyword">return</span> <span class="hljs-title class_">MPComponent</span>(options)<br>  &#125;;<br>&#125;<br><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">PAGE_EVENT_HOOKS</span> = [<br>  <span class="hljs-string">&#x27;onPullDownRefresh&#x27;</span>,<br>  <span class="hljs-string">&#x27;onReachBottom&#x27;</span>,<br>  <span class="hljs-string">&#x27;onAddToFavorites&#x27;</span>,<br>  <span class="hljs-string">&#x27;onShareTimeline&#x27;</span>,<br>  <span class="hljs-string">&#x27;onShareAppMessage&#x27;</span>,<br>  <span class="hljs-string">&#x27;onPageScroll&#x27;</span>,<br>  <span class="hljs-string">&#x27;onResize&#x27;</span>,<br>  <span class="hljs-string">&#x27;onTabItemTap&#x27;</span><br>];<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initMocks</span> (vm, mocks) &#123;<br>  <span class="hljs-keyword">const</span> mpInstance = vm.<span class="hljs-property">$mp</span>[vm.<span class="hljs-property">mpType</span>];<br>  mocks.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">mock</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-title function_">hasOwn</span>(mpInstance, mock)) &#123;<br>      vm[mock] = mpInstance[mock];<br>    &#125;<br>  &#125;);<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">hasHook</span> (hook, vueOptions) &#123;<br>  <span class="hljs-keyword">if</span> (!vueOptions) &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span><br>  &#125;<br><br>  <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Vue</span>.<span class="hljs-property">options</span> &amp;&amp; <span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(<span class="hljs-title class_">Vue</span>.<span class="hljs-property">options</span>[hook])) &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span><br>  &#125;<br><br>  vueOptions = vueOptions.<span class="hljs-property">default</span> || vueOptions;<br><br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(vueOptions)) &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(vueOptions.<span class="hljs-property">extendOptions</span>[hook])) &#123;<br>      <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span><br>    &#125;<br>    <span class="hljs-keyword">if</span> (vueOptions.<span class="hljs-property">super</span> &amp;&amp;<br>      vueOptions.<span class="hljs-property">super</span>.<span class="hljs-property">options</span> &amp;&amp;<br>      <span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(vueOptions.<span class="hljs-property">super</span>.<span class="hljs-property">options</span>[hook])) &#123;<br>      <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span><br>    &#125;<br>    <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span><br>  &#125;<br><br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(vueOptions[hook])) &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span><br>  &#125;<br>  <span class="hljs-keyword">const</span> mixins = vueOptions.<span class="hljs-property">mixins</span>;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(mixins)) &#123;<br>    <span class="hljs-keyword">return</span> !!mixins.<span class="hljs-title function_">find</span>(<span class="hljs-function"><span class="hljs-params">mixin</span> =&gt;</span> <span class="hljs-title function_">hasHook</span>(hook, mixin))<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initHooks</span> (mpOptions, hooks, vueOptions) &#123;<br>  hooks.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">hook</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-title function_">hasHook</span>(hook, vueOptions)) &#123;<br>      mpOptions[hook] = <span class="hljs-keyword">function</span> (<span class="hljs-params">args</span>) &#123;<br>        <span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span> &amp;&amp; <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-title function_">__call_hook</span>(hook, args)<br>      &#125;;<br>    &#125;<br>  &#125;);<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initVueComponent</span> (<span class="hljs-title class_">Vue</span>, vueOptions) &#123;<br>  vueOptions = vueOptions.<span class="hljs-property">default</span> || vueOptions;<br>  <span class="hljs-keyword">let</span> <span class="hljs-title class_">VueComponent</span>;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(vueOptions)) &#123;<br>    <span class="hljs-title class_">VueComponent</span> = vueOptions;<br>  &#125; <span class="hljs-keyword">else</span> &#123;<br>    <span class="hljs-title class_">VueComponent</span> = <span class="hljs-title class_">Vue</span>.<span class="hljs-title function_">extend</span>(vueOptions);<br>  &#125;<br>  vueOptions = <span class="hljs-title class_">VueComponent</span>.<span class="hljs-property">options</span>;<br>  <span class="hljs-keyword">return</span> [<span class="hljs-title class_">VueComponent</span>, vueOptions]<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initSlots</span> (vm, vueSlots) &#123;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(vueSlots) &amp;&amp; vueSlots.<span class="hljs-property">length</span>) &#123;<br>    <span class="hljs-keyword">const</span> $slots = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">create</span>(<span class="hljs-literal">null</span>);<br>    vueSlots.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">slotName</span> =&gt;</span> &#123;<br>      $slots[slotName] = <span class="hljs-literal">true</span>;<br>    &#125;);<br>    vm.<span class="hljs-property">$scopedSlots</span> = vm.<span class="hljs-property">$slots</span> = $slots;<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initVueIds</span> (vueIds, mpInstance) &#123;<br>  vueIds = (vueIds || <span class="hljs-string">&#x27;&#x27;</span>).<span class="hljs-title function_">split</span>(<span class="hljs-string">&#x27;,&#x27;</span>);<br>  <span class="hljs-keyword">const</span> len = vueIds.<span class="hljs-property">length</span>;<br><br>  <span class="hljs-keyword">if</span> (len === <span class="hljs-number">1</span>) &#123;<br>    mpInstance.<span class="hljs-property">_$vueId</span> = vueIds[<span class="hljs-number">0</span>];<br>  &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (len === <span class="hljs-number">2</span>) &#123;<br>    mpInstance.<span class="hljs-property">_$vueId</span> = vueIds[<span class="hljs-number">0</span>];<br>    mpInstance.<span class="hljs-property">_$vuePid</span> = vueIds[<span class="hljs-number">1</span>];<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initData</span> (vueOptions, context) &#123;<br>  <span class="hljs-keyword">let</span> data = vueOptions.<span class="hljs-property">data</span> || &#123;&#125;;<br>  <span class="hljs-keyword">const</span> methods = vueOptions.<span class="hljs-property">methods</span> || &#123;&#125;;<br><br>  <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> data === <span class="hljs-string">&#x27;function&#x27;</span>) &#123;<br>    <span class="hljs-keyword">try</span> &#123;<br>      data = data.<span class="hljs-title function_">call</span>(context); <span class="hljs-comment">// 支持 Vue.prototype 上挂的数据</span><br>    &#125; <span class="hljs-keyword">catch</span> (e) &#123;<br>      <span class="hljs-keyword">if</span> (process.<span class="hljs-property">env</span>.<span class="hljs-property">VUE_APP_DEBUG</span>) &#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">warn</span>(<span class="hljs-string">&#x27;根据 Vue 的 data 函数初始化小程序 data 失败，请尽量确保 data 函数中不访问 vm 对象，否则可能影响首次数据渲染速度。&#x27;</span>, data);<br>      &#125;<br>    &#125;<br>  &#125; <span class="hljs-keyword">else</span> &#123;<br>    <span class="hljs-keyword">try</span> &#123;<br>      <span class="hljs-comment">// 对 data 格式化</span><br>      data = <span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">parse</span>(<span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">stringify</span>(data));<br>    &#125; <span class="hljs-keyword">catch</span> (e) &#123;&#125;<br>  &#125;<br><br>  <span class="hljs-keyword">if</span> (!<span class="hljs-title function_">isPlainObject</span>(data)) &#123;<br>    data = &#123;&#125;;<br>  &#125;<br><br>  <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(methods).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">methodName</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">if</span> (context.<span class="hljs-property">__lifecycle_hooks__</span>.<span class="hljs-title function_">indexOf</span>(methodName) === -<span class="hljs-number">1</span> &amp;&amp; !<span class="hljs-title function_">hasOwn</span>(data, methodName)) &#123;<br>      data[methodName] = methods[methodName];<br>    &#125;<br>  &#125;);<br><br>  <span class="hljs-keyword">return</span> data<br>&#125;<br><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">PROP_TYPES</span> = [<span class="hljs-title class_">String</span>, <span class="hljs-title class_">Number</span>, <span class="hljs-title class_">Boolean</span>, <span class="hljs-title class_">Object</span>, <span class="hljs-title class_">Array</span>, <span class="hljs-literal">null</span>];<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">createObserver</span> (name) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">observer</span> (newVal, oldVal) &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>) &#123;<br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>[name] = newVal; <span class="hljs-comment">// 为了触发其他非 render watcher</span><br>    &#125;<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initBehaviors</span> (vueOptions, initBehavior) &#123;<br>  <span class="hljs-keyword">const</span> vueBehaviors = vueOptions.<span class="hljs-property">behaviors</span>;<br>  <span class="hljs-keyword">const</span> vueExtends = vueOptions.<span class="hljs-property">extends</span>;<br>  <span class="hljs-keyword">const</span> vueMixins = vueOptions.<span class="hljs-property">mixins</span>;<br><br>  <span class="hljs-keyword">let</span> vueProps = vueOptions.<span class="hljs-property">props</span>;<br><br>  <span class="hljs-keyword">if</span> (!vueProps) &#123;<br>    vueOptions.<span class="hljs-property">props</span> = vueProps = [];<br>  &#125;<br><br>  <span class="hljs-keyword">const</span> behaviors = [];<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(vueBehaviors)) &#123;<br>    vueBehaviors.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">behavior</span> =&gt;</span> &#123;<br>      behaviors.<span class="hljs-title function_">push</span>(behavior.<span class="hljs-title function_">replace</span>(<span class="hljs-string">&#x27;uni://&#x27;</span>, <span class="hljs-string">`<span class="hljs-subst">$&#123;<span class="hljs-string">&quot;wx&quot;</span>&#125;</span>://`</span>));<br>      <span class="hljs-keyword">if</span> (behavior === <span class="hljs-string">&#x27;uni://form-field&#x27;</span>) &#123;<br>        <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(vueProps)) &#123;<br>          vueProps.<span class="hljs-title function_">push</span>(<span class="hljs-string">&#x27;name&#x27;</span>);<br>          vueProps.<span class="hljs-title function_">push</span>(<span class="hljs-string">&#x27;value&#x27;</span>);<br>        &#125; <span class="hljs-keyword">else</span> &#123;<br>          vueProps.<span class="hljs-property">name</span> = &#123;<br>            <span class="hljs-attr">type</span>: <span class="hljs-title class_">String</span>,<br>            <span class="hljs-attr">default</span>: <span class="hljs-string">&#x27;&#x27;</span><br>          &#125;;<br>          vueProps.<span class="hljs-property">value</span> = &#123;<br>            <span class="hljs-attr">type</span>: [<span class="hljs-title class_">String</span>, <span class="hljs-title class_">Number</span>, <span class="hljs-title class_">Boolean</span>, <span class="hljs-title class_">Array</span>, <span class="hljs-title class_">Object</span>, <span class="hljs-title class_">Date</span>],<br>            <span class="hljs-attr">default</span>: <span class="hljs-string">&#x27;&#x27;</span><br>          &#125;;<br>        &#125;<br>      &#125;<br>    &#125;);<br>  &#125;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPlainObject</span>(vueExtends) &amp;&amp; vueExtends.<span class="hljs-property">props</span>) &#123;<br>    behaviors.<span class="hljs-title function_">push</span>(<br>      <span class="hljs-title function_">initBehavior</span>(&#123;<br>        <span class="hljs-attr">properties</span>: <span class="hljs-title function_">initProperties</span>(vueExtends.<span class="hljs-property">props</span>, <span class="hljs-literal">true</span>)<br>      &#125;)<br>    );<br>  &#125;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(vueMixins)) &#123;<br>    vueMixins.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">vueMixin</span> =&gt;</span> &#123;<br>      <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPlainObject</span>(vueMixin) &amp;&amp; vueMixin.<span class="hljs-property">props</span>) &#123;<br>        behaviors.<span class="hljs-title function_">push</span>(<br>          <span class="hljs-title function_">initBehavior</span>(&#123;<br>            <span class="hljs-attr">properties</span>: <span class="hljs-title function_">initProperties</span>(vueMixin.<span class="hljs-property">props</span>, <span class="hljs-literal">true</span>)<br>          &#125;)<br>        );<br>      &#125;<br>    &#125;);<br>  &#125;<br>  <span class="hljs-keyword">return</span> behaviors<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">parsePropType</span> (key, type, defaultValue, file) &#123;<br>  <span class="hljs-comment">// [String]=&gt;String</span><br>  <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(type) &amp;&amp; type.<span class="hljs-property">length</span> === <span class="hljs-number">1</span>) &#123;<br>    <span class="hljs-keyword">return</span> type[<span class="hljs-number">0</span>]<br>  &#125;<br>  <span class="hljs-keyword">return</span> type<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initProperties</span> (props, isBehavior = <span class="hljs-literal">false</span>, file = <span class="hljs-string">&#x27;&#x27;</span>) &#123;<br>  <span class="hljs-keyword">const</span> properties = &#123;&#125;;<br>  <span class="hljs-keyword">if</span> (!isBehavior) &#123;<br>    properties.<span class="hljs-property">vueId</span> = &#123;<br>      <span class="hljs-attr">type</span>: <span class="hljs-title class_">String</span>,<br>      <span class="hljs-attr">value</span>: <span class="hljs-string">&#x27;&#x27;</span><br>    &#125;;<br>    <span class="hljs-comment">// 用于字节跳动小程序模拟抽象节点</span><br>    properties.<span class="hljs-property">generic</span> = &#123;<br>      <span class="hljs-attr">type</span>: <span class="hljs-title class_">Object</span>,<br>      <span class="hljs-attr">value</span>: <span class="hljs-literal">null</span><br>    &#125;;<br>    properties.<span class="hljs-property">vueSlots</span> = &#123; <span class="hljs-comment">// 小程序不能直接定义 $slots 的 props，所以通过 vueSlots 转换到 $slots</span><br>      <span class="hljs-attr">type</span>: <span class="hljs-literal">null</span>,<br>      <span class="hljs-attr">value</span>: [],<br>      <span class="hljs-attr">observer</span>: <span class="hljs-keyword">function</span> (<span class="hljs-params">newVal, oldVal</span>) &#123;<br>        <span class="hljs-keyword">const</span> $slots = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">create</span>(<span class="hljs-literal">null</span>);<br>        newVal.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">slotName</span> =&gt;</span> &#123;<br>          $slots[slotName] = <span class="hljs-literal">true</span>;<br>        &#125;);<br>        <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setData</span>(&#123;<br>          $slots<br>        &#125;);<br>      &#125;<br>    &#125;;<br>  &#125;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(props)) &#123; <span class="hljs-comment">// [&#x27;title&#x27;]</span><br>    props.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">key</span> =&gt;</span> &#123;<br>      properties[key] = &#123;<br>        <span class="hljs-attr">type</span>: <span class="hljs-literal">null</span>,<br>        <span class="hljs-attr">observer</span>: <span class="hljs-title function_">createObserver</span>(key)<br>      &#125;;<br>    &#125;);<br>  &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPlainObject</span>(props)) &#123; <span class="hljs-comment">// &#123;title:&#123;type:String,default:&#x27;&#x27;&#125;,content:String&#125;</span><br>    <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(props).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">key</span> =&gt;</span> &#123;<br>      <span class="hljs-keyword">const</span> opts = props[key];<br>      <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPlainObject</span>(opts)) &#123; <span class="hljs-comment">// title:&#123;type:String,default:&#x27;&#x27;&#125;</span><br>        <span class="hljs-keyword">let</span> value = opts.<span class="hljs-property">default</span>;<br>        <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(value)) &#123;<br>          value = <span class="hljs-title function_">value</span>();<br>        &#125;<br><br>        opts.<span class="hljs-property">type</span> = <span class="hljs-title function_">parsePropType</span>(key, opts.<span class="hljs-property">type</span>);<br><br>        properties[key] = &#123;<br>          <span class="hljs-attr">type</span>: <span class="hljs-variable constant_">PROP_TYPES</span>.<span class="hljs-title function_">indexOf</span>(opts.<span class="hljs-property">type</span>) !== -<span class="hljs-number">1</span> ? opts.<span class="hljs-property">type</span> : <span class="hljs-literal">null</span>,<br>          value,<br>          <span class="hljs-attr">observer</span>: <span class="hljs-title function_">createObserver</span>(key)<br>        &#125;;<br>      &#125; <span class="hljs-keyword">else</span> &#123; <span class="hljs-comment">// content:String</span><br>        <span class="hljs-keyword">const</span> type = <span class="hljs-title function_">parsePropType</span>(key, opts);<br>        properties[key] = &#123;<br>          <span class="hljs-attr">type</span>: <span class="hljs-variable constant_">PROP_TYPES</span>.<span class="hljs-title function_">indexOf</span>(type) !== -<span class="hljs-number">1</span> ? type : <span class="hljs-literal">null</span>,<br>          <span class="hljs-attr">observer</span>: <span class="hljs-title function_">createObserver</span>(key)<br>        &#125;;<br>      &#125;<br>    &#125;);<br>  &#125;<br>  <span class="hljs-keyword">return</span> properties<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">wrapper$1</span> (event) &#123;<br>  <span class="hljs-comment">// TODO 又得兼容 mpvue 的 mp 对象</span><br>  <span class="hljs-keyword">try</span> &#123;<br>    event.<span class="hljs-property">mp</span> = <span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">parse</span>(<span class="hljs-title class_">JSON</span>.<span class="hljs-title function_">stringify</span>(event));<br>  &#125; <span class="hljs-keyword">catch</span> (e) &#123;&#125;<br><br>  event.<span class="hljs-property">stopPropagation</span> = noop;<br>  event.<span class="hljs-property">preventDefault</span> = noop;<br><br>  event.<span class="hljs-property">target</span> = event.<span class="hljs-property">target</span> || &#123;&#125;;<br><br>  <span class="hljs-keyword">if</span> (!<span class="hljs-title function_">hasOwn</span>(event, <span class="hljs-string">&#x27;detail&#x27;</span>)) &#123;<br>    event.<span class="hljs-property">detail</span> = &#123;&#125;;<br>  &#125;<br><br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">hasOwn</span>(event, <span class="hljs-string">&#x27;markerId&#x27;</span>)) &#123;<br>    event.<span class="hljs-property">detail</span> = <span class="hljs-keyword">typeof</span> event.<span class="hljs-property">detail</span> === <span class="hljs-string">&#x27;object&#x27;</span> ? event.<span class="hljs-property">detail</span> : &#123;&#125;;<br>    event.<span class="hljs-property">detail</span>.<span class="hljs-property">markerId</span> = event.<span class="hljs-property">markerId</span>;<br>  &#125;<br><br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPlainObject</span>(event.<span class="hljs-property">detail</span>)) &#123;<br>    event.<span class="hljs-property">target</span> = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">assign</span>(&#123;&#125;, event.<span class="hljs-property">target</span>, event.<span class="hljs-property">detail</span>);<br>  &#125;<br><br>  <span class="hljs-keyword">return</span> event<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">getExtraValue</span> (vm, dataPathsArray) &#123;<br>  <span class="hljs-keyword">let</span> context = vm;<br>  dataPathsArray.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">dataPathArray</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">const</span> dataPath = dataPathArray[<span class="hljs-number">0</span>];<br>    <span class="hljs-keyword">const</span> value = dataPathArray[<span class="hljs-number">2</span>];<br>    <span class="hljs-keyword">if</span> (dataPath || <span class="hljs-keyword">typeof</span> value !== <span class="hljs-string">&#x27;undefined&#x27;</span>) &#123; <span class="hljs-comment">// [&#x27;&#x27;,&#x27;&#x27;,index,&#x27;disable&#x27;]</span><br>      <span class="hljs-keyword">const</span> propPath = dataPathArray[<span class="hljs-number">1</span>];<br>      <span class="hljs-keyword">const</span> valuePath = dataPathArray[<span class="hljs-number">3</span>];<br><br>      <span class="hljs-keyword">let</span> vFor;<br>      <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Number</span>.<span class="hljs-title function_">isInteger</span>(dataPath)) &#123;<br>        vFor = dataPath;<br>      &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (!dataPath) &#123;<br>        vFor = context;<br>      &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> dataPath === <span class="hljs-string">&#x27;string&#x27;</span> &amp;&amp; dataPath) &#123;<br>        <span class="hljs-keyword">if</span> (dataPath.<span class="hljs-title function_">indexOf</span>(<span class="hljs-string">&#x27;#s#&#x27;</span>) === <span class="hljs-number">0</span>) &#123;<br>          vFor = dataPath.<span class="hljs-title function_">substr</span>(<span class="hljs-number">3</span>);<br>        &#125; <span class="hljs-keyword">else</span> &#123;<br>          vFor = vm.<span class="hljs-title function_">__get_value</span>(dataPath, context);<br>        &#125;<br>      &#125;<br><br>      <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Number</span>.<span class="hljs-title function_">isInteger</span>(vFor)) &#123;<br>        context = value;<br>      &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (!propPath) &#123;<br>        context = vFor[value];<br>      &#125; <span class="hljs-keyword">else</span> &#123;<br>        <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(vFor)) &#123;<br>          context = vFor.<span class="hljs-title function_">find</span>(<span class="hljs-function"><span class="hljs-params">vForItem</span> =&gt;</span> &#123;<br>            <span class="hljs-keyword">return</span> vm.<span class="hljs-title function_">__get_value</span>(propPath, vForItem) === value<br>          &#125;);<br>        &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isPlainObject</span>(vFor)) &#123;<br>          context = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(vFor).<span class="hljs-title function_">find</span>(<span class="hljs-function"><span class="hljs-params">vForKey</span> =&gt;</span> &#123;<br>            <span class="hljs-keyword">return</span> vm.<span class="hljs-title function_">__get_value</span>(propPath, vFor[vForKey]) === value<br>          &#125;);<br>        &#125; <span class="hljs-keyword">else</span> &#123;<br>          <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">&#x27;v-for 暂不支持循环数据：&#x27;</span>, vFor);<br>        &#125;<br>      &#125;<br><br>      <span class="hljs-keyword">if</span> (valuePath) &#123;<br>        context = vm.<span class="hljs-title function_">__get_value</span>(valuePath, context);<br>      &#125;<br>    &#125;<br>  &#125;);<br>  <span class="hljs-keyword">return</span> context<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">processEventExtra</span> (vm, extra, event) &#123;<br>  <span class="hljs-keyword">const</span> extraObj = &#123;&#125;;<br><br>  <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(extra) &amp;&amp; extra.<span class="hljs-property">length</span>) &#123;<br>    <span class="hljs-comment">/**</span><br><span class="hljs-comment">     *[</span><br><span class="hljs-comment">     *    [&#x27;data.items&#x27;, &#x27;data.id&#x27;, item.data.id],</span><br><span class="hljs-comment">     *    [&#x27;metas&#x27;, &#x27;id&#x27;, meta.id]</span><br><span class="hljs-comment">     *],</span><br><span class="hljs-comment">     *[</span><br><span class="hljs-comment">     *    [&#x27;data.items&#x27;, &#x27;data.id&#x27;, item.data.id],</span><br><span class="hljs-comment">     *    [&#x27;metas&#x27;, &#x27;id&#x27;, meta.id]</span><br><span class="hljs-comment">     *],</span><br><span class="hljs-comment">     *&#x27;test&#x27;</span><br><span class="hljs-comment">     */</span><br>    extra.<span class="hljs-title function_">forEach</span>(<span class="hljs-function">(<span class="hljs-params">dataPath, index</span>) =&gt;</span> &#123;<br>      <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> dataPath === <span class="hljs-string">&#x27;string&#x27;</span>) &#123;<br>        <span class="hljs-keyword">if</span> (!dataPath) &#123; <span class="hljs-comment">// model,prop.sync</span><br>          extraObj[<span class="hljs-string">&#x27;$&#x27;</span> + index] = vm;<br>        &#125; <span class="hljs-keyword">else</span> &#123;<br>          <span class="hljs-keyword">if</span> (dataPath === <span class="hljs-string">&#x27;$event&#x27;</span>) &#123; <span class="hljs-comment">// $event</span><br>            extraObj[<span class="hljs-string">&#x27;$&#x27;</span> + index] = event;<br>          &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (dataPath === <span class="hljs-string">&#x27;arguments&#x27;</span>) &#123;<br>            <span class="hljs-keyword">if</span> (event.<span class="hljs-property">detail</span> &amp;&amp; event.<span class="hljs-property">detail</span>.<span class="hljs-property">__args__</span>) &#123;<br>              extraObj[<span class="hljs-string">&#x27;$&#x27;</span> + index] = event.<span class="hljs-property">detail</span>.<span class="hljs-property">__args__</span>;<br>            &#125; <span class="hljs-keyword">else</span> &#123;<br>              extraObj[<span class="hljs-string">&#x27;$&#x27;</span> + index] = [event];<br>            &#125;<br>          &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (dataPath.<span class="hljs-title function_">indexOf</span>(<span class="hljs-string">&#x27;$event.&#x27;</span>) === <span class="hljs-number">0</span>) &#123; <span class="hljs-comment">// $event.target.value</span><br>            extraObj[<span class="hljs-string">&#x27;$&#x27;</span> + index] = vm.<span class="hljs-title function_">__get_value</span>(dataPath.<span class="hljs-title function_">replace</span>(<span class="hljs-string">&#x27;$event.&#x27;</span>, <span class="hljs-string">&#x27;&#x27;</span>), event);<br>          &#125; <span class="hljs-keyword">else</span> &#123;<br>            extraObj[<span class="hljs-string">&#x27;$&#x27;</span> + index] = vm.<span class="hljs-title function_">__get_value</span>(dataPath);<br>          &#125;<br>        &#125;<br>      &#125; <span class="hljs-keyword">else</span> &#123;<br>        extraObj[<span class="hljs-string">&#x27;$&#x27;</span> + index] = <span class="hljs-title function_">getExtraValue</span>(vm, dataPath);<br>      &#125;<br>    &#125;);<br>  &#125;<br><br>  <span class="hljs-keyword">return</span> extraObj<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">getObjByArray</span> (arr) &#123;<br>  <span class="hljs-keyword">const</span> obj = &#123;&#125;;<br>  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">1</span>; i &lt; arr.<span class="hljs-property">length</span>; i++) &#123;<br>    <span class="hljs-keyword">const</span> element = arr[i];<br>    obj[element[<span class="hljs-number">0</span>]] = element[<span class="hljs-number">1</span>];<br>  &#125;<br>  <span class="hljs-keyword">return</span> obj<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">processEventArgs</span> (vm, event, args = [], extra = [], isCustom, methodName) &#123;<br>  <span class="hljs-keyword">let</span> isCustomMPEvent = <span class="hljs-literal">false</span>; <span class="hljs-comment">// wxcomponent 组件，传递原始 event 对象</span><br>  <span class="hljs-keyword">if</span> (isCustom) &#123; <span class="hljs-comment">// 自定义事件</span><br>    isCustomMPEvent = event.<span class="hljs-property">currentTarget</span> &amp;&amp;<br>      event.<span class="hljs-property">currentTarget</span>.<span class="hljs-property">dataset</span> &amp;&amp;<br>      event.<span class="hljs-property">currentTarget</span>.<span class="hljs-property">dataset</span>.<span class="hljs-property">comType</span> === <span class="hljs-string">&#x27;wx&#x27;</span>;<br>    <span class="hljs-keyword">if</span> (!args.<span class="hljs-property">length</span>) &#123; <span class="hljs-comment">// 无参数，直接传入 event 或 detail 数组</span><br>      <span class="hljs-keyword">if</span> (isCustomMPEvent) &#123;<br>        <span class="hljs-keyword">return</span> [event]<br>      &#125;<br>      <span class="hljs-keyword">return</span> event.<span class="hljs-property">detail</span>.<span class="hljs-property">__args__</span> || event.<span class="hljs-property">detail</span><br>    &#125;<br>  &#125;<br><br>  <span class="hljs-keyword">const</span> extraObj = <span class="hljs-title function_">processEventExtra</span>(vm, extra, event);<br><br>  <span class="hljs-keyword">const</span> ret = [];<br>  args.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">arg</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">if</span> (arg === <span class="hljs-string">&#x27;$event&#x27;</span>) &#123;<br>      <span class="hljs-keyword">if</span> (methodName === <span class="hljs-string">&#x27;__set_model&#x27;</span> &amp;&amp; !isCustom) &#123; <span class="hljs-comment">// input v-model value</span><br>        ret.<span class="hljs-title function_">push</span>(event.<span class="hljs-property">target</span>.<span class="hljs-property">value</span>);<br>      &#125; <span class="hljs-keyword">else</span> &#123;<br>        <span class="hljs-keyword">if</span> (isCustom &amp;&amp; !isCustomMPEvent) &#123;<br>          ret.<span class="hljs-title function_">push</span>(event.<span class="hljs-property">detail</span>.<span class="hljs-property">__args__</span>[<span class="hljs-number">0</span>]);<br>        &#125; <span class="hljs-keyword">else</span> &#123; <span class="hljs-comment">// wxcomponent 组件或内置组件</span><br>          ret.<span class="hljs-title function_">push</span>(event);<br>        &#125;<br>      &#125;<br>    &#125; <span class="hljs-keyword">else</span> &#123;<br>      <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(arg) &amp;&amp; arg[<span class="hljs-number">0</span>] === <span class="hljs-string">&#x27;o&#x27;</span>) &#123;<br>        ret.<span class="hljs-title function_">push</span>(<span class="hljs-title function_">getObjByArray</span>(arg));<br>      &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> arg === <span class="hljs-string">&#x27;string&#x27;</span> &amp;&amp; <span class="hljs-title function_">hasOwn</span>(extraObj, arg)) &#123;<br>        ret.<span class="hljs-title function_">push</span>(extraObj[arg]);<br>      &#125; <span class="hljs-keyword">else</span> &#123;<br>        ret.<span class="hljs-title function_">push</span>(arg);<br>      &#125;<br>    &#125;<br>  &#125;);<br><br>  <span class="hljs-keyword">return</span> ret<br>&#125;<br><br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">ONCE</span> = <span class="hljs-string">&#x27;~&#x27;</span>;<br><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">CUSTOM</span> = <span class="hljs-string">&#x27;^&#x27;</span>;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">isMatchEventType</span> (eventType, optType) &#123;<br>  <span class="hljs-keyword">return</span> (eventType === optType) ||<br>    (<br>      optType === <span class="hljs-string">&#x27;regionchange&#x27;</span> &amp;&amp;<br>      (<br>        eventType === <span class="hljs-string">&#x27;begin&#x27;</span> ||<br>        eventType === <span class="hljs-string">&#x27;end&#x27;</span><br>      )<br>    )<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">getContextVm</span> (vm) &#123;<br>  <span class="hljs-keyword">let</span> $parent = vm.<span class="hljs-property">$parent</span>;<br>  <span class="hljs-comment">// 父组件是 scoped slots 或者其他自定义组件时继续查找</span><br>  <span class="hljs-keyword">while</span> ($parent &amp;&amp; $parent.<span class="hljs-property">$parent</span> &amp;&amp; ($parent.<span class="hljs-property">$options</span>.<span class="hljs-property">generic</span> || $parent.<span class="hljs-property">$parent</span>.<span class="hljs-property">$options</span>.<span class="hljs-property">generic</span> || $parent.<span class="hljs-property">$scope</span>.<span class="hljs-property">_$vuePid</span>)) &#123;<br>    $parent = $parent.<span class="hljs-property">$parent</span>;<br>  &#125;<br>  <span class="hljs-keyword">return</span> $parent &amp;&amp; $parent.<span class="hljs-property">$parent</span><br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">handleEvent</span> (event) &#123;<br>  event = <span class="hljs-title function_">wrapper$1</span>(event);<br><br>  <span class="hljs-comment">// [[&#x27;tap&#x27;,[[&#x27;handle&#x27;,[1,2,a]],[&#x27;handle1&#x27;,[1,2,a]]]]]</span><br>  <span class="hljs-keyword">const</span> dataset = (event.<span class="hljs-property">currentTarget</span> || event.<span class="hljs-property">target</span>).<span class="hljs-property">dataset</span>;<br>  <span class="hljs-keyword">if</span> (!dataset) &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">warn</span>(<span class="hljs-string">&#x27;事件信息不存在&#x27;</span>)<br>  &#125;<br>  <span class="hljs-keyword">const</span> eventOpts = dataset.<span class="hljs-property">eventOpts</span> || dataset[<span class="hljs-string">&#x27;event-opts&#x27;</span>]; <span class="hljs-comment">// 支付宝 web-view 组件 dataset 非驼峰</span><br>  <span class="hljs-keyword">if</span> (!eventOpts) &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">warn</span>(<span class="hljs-string">&#x27;事件信息不存在&#x27;</span>)<br>  &#125;<br><br>  <span class="hljs-comment">// [[&#x27;handle&#x27;,[1,2,a]],[&#x27;handle1&#x27;,[1,2,a]]]</span><br>  <span class="hljs-keyword">const</span> eventType = event.<span class="hljs-property">type</span>;<br><br>  <span class="hljs-keyword">const</span> ret = [];<br><br>  eventOpts.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">eventOpt</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">let</span> type = eventOpt[<span class="hljs-number">0</span>];<br>    <span class="hljs-keyword">const</span> eventsArray = eventOpt[<span class="hljs-number">1</span>];<br><br>    <span class="hljs-keyword">const</span> isCustom = type.<span class="hljs-title function_">charAt</span>(<span class="hljs-number">0</span>) === <span class="hljs-variable constant_">CUSTOM</span>;<br>    type = isCustom ? type.<span class="hljs-title function_">slice</span>(<span class="hljs-number">1</span>) : type;<br>    <span class="hljs-keyword">const</span> isOnce = type.<span class="hljs-title function_">charAt</span>(<span class="hljs-number">0</span>) === <span class="hljs-variable constant_">ONCE</span>;<br>    type = isOnce ? type.<span class="hljs-title function_">slice</span>(<span class="hljs-number">1</span>) : type;<br><br>    <span class="hljs-keyword">if</span> (eventsArray &amp;&amp; <span class="hljs-title function_">isMatchEventType</span>(eventType, type)) &#123;<br>      eventsArray.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">eventArray</span> =&gt;</span> &#123;<br>        <span class="hljs-keyword">const</span> methodName = eventArray[<span class="hljs-number">0</span>];<br>        <span class="hljs-keyword">if</span> (methodName) &#123;<br>          <span class="hljs-keyword">let</span> handlerCtx = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>;<br>          <span class="hljs-keyword">if</span> (handlerCtx.<span class="hljs-property">$options</span>.<span class="hljs-property">generic</span>) &#123; <span class="hljs-comment">// mp-weixin,mp-toutiao 抽象节点模拟 scoped slots</span><br>            handlerCtx = <span class="hljs-title function_">getContextVm</span>(handlerCtx) || handlerCtx;<br>          &#125;<br>          <span class="hljs-keyword">if</span> (methodName === <span class="hljs-string">&#x27;$emit&#x27;</span>) &#123;<br>            handlerCtx.<span class="hljs-property">$emit</span>.<span class="hljs-title function_">apply</span>(handlerCtx,<br>              <span class="hljs-title function_">processEventArgs</span>(<br>                <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>,<br>                event,<br>                eventArray[<span class="hljs-number">1</span>],<br>                eventArray[<span class="hljs-number">2</span>],<br>                isCustom,<br>                methodName<br>              ));<br>            <span class="hljs-keyword">return</span><br>          &#125;<br>          <span class="hljs-keyword">const</span> handler = handlerCtx[methodName];<br>          <span class="hljs-keyword">if</span> (!<span class="hljs-title function_">isFn</span>(handler)) &#123;<br>            <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Error</span>(<span class="hljs-string">` _vm.<span class="hljs-subst">$&#123;methodName&#125;</span> is not a function`</span>)<br>          &#125;<br>          <span class="hljs-keyword">if</span> (isOnce) &#123;<br>            <span class="hljs-keyword">if</span> (handler.<span class="hljs-property">once</span>) &#123;<br>              <span class="hljs-keyword">return</span><br>            &#125;<br>            handler.<span class="hljs-property">once</span> = <span class="hljs-literal">true</span>;<br>          &#125;<br>          <span class="hljs-keyword">let</span> params = <span class="hljs-title function_">processEventArgs</span>(<br>            <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>,<br>            event,<br>            eventArray[<span class="hljs-number">1</span>],<br>            eventArray[<span class="hljs-number">2</span>],<br>            isCustom,<br>            methodName<br>          );<br>          params = <span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(params) ? params : [];<br>          <span class="hljs-comment">// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据</span><br>          <span class="hljs-keyword">if</span> (<span class="hljs-regexp">/=\s*\S+\.eventParams\s*\|\|\s*\S+\[[&#x27;&quot;]event-params[&#x27;&quot;]\]/</span>.<span class="hljs-title function_">test</span>(handler.<span class="hljs-title function_">toString</span>())) &#123;<br>            <span class="hljs-comment">// eslint-disable-next-line no-sparse-arrays</span><br>            params = params.<span class="hljs-title function_">concat</span>([, , , , , , , , , , event]);<br>          &#125;<br>          ret.<span class="hljs-title function_">push</span>(handler.<span class="hljs-title function_">apply</span>(handlerCtx, params));<br>        &#125;<br>      &#125;);<br>    &#125;<br>  &#125;);<br><br>  <span class="hljs-keyword">if</span> (<br>    eventType === <span class="hljs-string">&#x27;input&#x27;</span> &amp;&amp;<br>    ret.<span class="hljs-property">length</span> === <span class="hljs-number">1</span> &amp;&amp;<br>    <span class="hljs-keyword">typeof</span> ret[<span class="hljs-number">0</span>] !== <span class="hljs-string">&#x27;undefined&#x27;</span><br>  ) &#123;<br>    <span class="hljs-keyword">return</span> ret[<span class="hljs-number">0</span>]<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">const</span> eventChannels = &#123;&#125;;<br><br><span class="hljs-keyword">const</span> eventChannelStack = [];<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">getEventChannel</span> (id) &#123;<br>  <span class="hljs-keyword">if</span> (id) &#123;<br>    <span class="hljs-keyword">const</span> eventChannel = eventChannels[id];<br>    <span class="hljs-keyword">delete</span> eventChannels[id];<br>    <span class="hljs-keyword">return</span> eventChannel<br>  &#125;<br>  <span class="hljs-keyword">return</span> eventChannelStack.<span class="hljs-title function_">shift</span>()<br>&#125;<br><br><span class="hljs-keyword">const</span> hooks = [<br>  <span class="hljs-string">&#x27;onShow&#x27;</span>,<br>  <span class="hljs-string">&#x27;onHide&#x27;</span>,<br>  <span class="hljs-string">&#x27;onError&#x27;</span>,<br>  <span class="hljs-string">&#x27;onPageNotFound&#x27;</span>,<br>  <span class="hljs-string">&#x27;onThemeChange&#x27;</span>,<br>  <span class="hljs-string">&#x27;onUnhandledRejection&#x27;</span><br>];<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initEventChannel</span> () &#123;<br>  <span class="hljs-title class_">Vue</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">getOpenerEventChannel</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-comment">// 微信小程序使用自身getOpenerEventChannel</span><br>    &#123;<br>      <span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">$scope</span>.<span class="hljs-title function_">getOpenerEventChannel</span>()<br>    &#125;<br>  &#125;;<br>  <span class="hljs-keyword">const</span> callHook = <span class="hljs-title class_">Vue</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">__call_hook</span>;<br>  <span class="hljs-title class_">Vue</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">__call_hook</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">hook, args</span>) &#123;<br>    <span class="hljs-keyword">if</span> (hook === <span class="hljs-string">&#x27;onLoad&#x27;</span> &amp;&amp; args &amp;&amp; args.<span class="hljs-property">__id__</span>) &#123;<br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">__eventChannel__</span> = <span class="hljs-title function_">getEventChannel</span>(args.<span class="hljs-property">__id__</span>);<br>      <span class="hljs-keyword">delete</span> args.<span class="hljs-property">__id__</span>;<br>    &#125;<br>    <span class="hljs-keyword">return</span> callHook.<span class="hljs-title function_">call</span>(<span class="hljs-variable language_">this</span>, hook, args)<br>  &#125;;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initScopedSlotsParams</span> () &#123;<br>  <span class="hljs-keyword">const</span> center = &#123;&#125;;<br>  <span class="hljs-keyword">const</span> parents = &#123;&#125;;<br><br>  <span class="hljs-title class_">Vue</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">$hasScopedSlotsParams</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">vueId</span>) &#123;<br>    <span class="hljs-keyword">const</span> has = center[vueId];<br>    <span class="hljs-keyword">if</span> (!has) &#123;<br>      parents[vueId] = <span class="hljs-variable language_">this</span>;<br>      <span class="hljs-variable language_">this</span>.$on(<span class="hljs-string">&#x27;hook:destory&#x27;</span>, <span class="hljs-function">() =&gt;</span> &#123;<br>        <span class="hljs-keyword">delete</span> parents[vueId];<br>      &#125;);<br>    &#125;<br>    <span class="hljs-keyword">return</span> has<br>  &#125;;<br><br>  <span class="hljs-title class_">Vue</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">$getScopedSlotsParams</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">vueId, name, key</span>) &#123;<br>    <span class="hljs-keyword">const</span> data = center[vueId];<br>    <span class="hljs-keyword">if</span> (data) &#123;<br>      <span class="hljs-keyword">const</span> object = data[name] || &#123;&#125;;<br>      <span class="hljs-keyword">return</span> key ? object[key] : object<br>    &#125; <span class="hljs-keyword">else</span> &#123;<br>      parents[vueId] = <span class="hljs-variable language_">this</span>;<br>      <span class="hljs-variable language_">this</span>.$on(<span class="hljs-string">&#x27;hook:destory&#x27;</span>, <span class="hljs-function">() =&gt;</span> &#123;<br>        <span class="hljs-keyword">delete</span> parents[vueId];<br>      &#125;);<br>    &#125;<br>  &#125;;<br><br>  <span class="hljs-title class_">Vue</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">$setScopedSlotsParams</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">name, value</span>) &#123;<br>    <span class="hljs-keyword">const</span> vueId = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$options</span>.<span class="hljs-property">propsData</span>.<span class="hljs-property">vueId</span>;<br>    <span class="hljs-keyword">const</span> object = center[vueId] = center[vueId] || &#123;&#125;;<br>    object[name] = value;<br>    <span class="hljs-keyword">if</span> (parents[vueId]) &#123;<br>      parents[vueId].$forceUpdate();<br>    &#125;<br>  &#125;;<br><br>  <span class="hljs-title class_">Vue</span>.<span class="hljs-title function_">mixin</span>(&#123;<br>    destroyed () &#123;<br>      <span class="hljs-keyword">const</span> propsData = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$options</span>.<span class="hljs-property">propsData</span>;<br>      <span class="hljs-keyword">const</span> vueId = propsData &amp;&amp; propsData.<span class="hljs-property">vueId</span>;<br>      <span class="hljs-keyword">if</span> (vueId) &#123;<br>        <span class="hljs-keyword">delete</span> center[vueId];<br>        <span class="hljs-keyword">delete</span> parents[vueId];<br>      &#125;<br>    &#125;<br>  &#125;);<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">parseBaseApp</span> (vm, &#123;<br>  mocks,<br>  initRefs<br>&#125;) &#123;<br>  <span class="hljs-title function_">initEventChannel</span>();<br>  &#123;<br>    <span class="hljs-title function_">initScopedSlotsParams</span>();<br>  &#125;<br>  <span class="hljs-keyword">if</span> (vm.<span class="hljs-property">$options</span>.<span class="hljs-property">store</span>) &#123;<br>    <span class="hljs-title class_">Vue</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">$store</span> = vm.<span class="hljs-property">$options</span>.<span class="hljs-property">store</span>;<br>  &#125;<br><br>  <span class="hljs-title class_">Vue</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">mpHost</span> = <span class="hljs-string">&quot;mp-weixin&quot;</span>;<br><br>  <span class="hljs-title class_">Vue</span>.<span class="hljs-title function_">mixin</span>(&#123;<br>    beforeCreate () &#123;<br>      <span class="hljs-keyword">if</span> (!<span class="hljs-variable language_">this</span>.<span class="hljs-property">$options</span>.<span class="hljs-property">mpType</span>) &#123;<br>        <span class="hljs-keyword">return</span><br>      &#125;<br><br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">mpType</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$options</span>.<span class="hljs-property">mpType</span>;<br><br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">$mp</span> = &#123;<br>        <span class="hljs-attr">data</span>: &#123;&#125;,<br>        [<span class="hljs-variable language_">this</span>.<span class="hljs-property">mpType</span>]: <span class="hljs-variable language_">this</span>.<span class="hljs-property">$options</span>.<span class="hljs-property">mpInstance</span><br>      &#125;;<br><br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">$scope</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$options</span>.<span class="hljs-property">mpInstance</span>;<br><br>      <span class="hljs-keyword">delete</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">$options</span>.<span class="hljs-property">mpType</span>;<br>      <span class="hljs-keyword">delete</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">$options</span>.<span class="hljs-property">mpInstance</span>;<br>      <span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">mpType</span> === <span class="hljs-string">&#x27;page&#x27;</span> &amp;&amp; <span class="hljs-keyword">typeof</span> getApp === <span class="hljs-string">&#x27;function&#x27;</span>) &#123; <span class="hljs-comment">// hack vue-i18n</span><br>        <span class="hljs-keyword">const</span> app = <span class="hljs-title function_">getApp</span>();<br>        <span class="hljs-keyword">if</span> (app.<span class="hljs-property">$vm</span> &amp;&amp; app.<span class="hljs-property">$vm</span>.<span class="hljs-property">$i18n</span>) &#123;<br>          <span class="hljs-variable language_">this</span>.<span class="hljs-property">_i18n</span> = app.<span class="hljs-property">$vm</span>.<span class="hljs-property">$i18n</span>;<br>        &#125;<br>      &#125;<br>      <span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">mpType</span> !== <span class="hljs-string">&#x27;app&#x27;</span>) &#123;<br>        <span class="hljs-title function_">initRefs</span>(<span class="hljs-variable language_">this</span>);<br>        <span class="hljs-title function_">initMocks</span>(<span class="hljs-variable language_">this</span>, mocks);<br>      &#125;<br>    &#125;<br>  &#125;);<br><br>  <span class="hljs-keyword">const</span> appOptions = &#123;<br>    onLaunch (args) &#123;<br>      <span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>) &#123; <span class="hljs-comment">// 已经初始化过了，主要是为了百度，百度 onShow 在 onLaunch 之前</span><br>        <span class="hljs-keyword">return</span><br>      &#125;<br>      &#123;<br>        <span class="hljs-keyword">if</span> (wx.<span class="hljs-property">canIUse</span> &amp;&amp; !wx.<span class="hljs-title function_">canIUse</span>(<span class="hljs-string">&#x27;nextTick&#x27;</span>)) &#123; <span class="hljs-comment">// 事实 上2.2.3 即可，简单使用 2.3.0 的 nextTick 判断</span><br>          <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">&#x27;当前微信基础库版本过低，请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上&#x27;</span>);<br>        &#125;<br>      &#125;<br><br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span> = vm;<br><br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-property">$mp</span> = &#123;<br>        <span class="hljs-attr">app</span>: <span class="hljs-variable language_">this</span><br>      &#125;;<br><br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-property">$scope</span> = <span class="hljs-variable language_">this</span>;<br>      <span class="hljs-comment">// vm 上也挂载 globalData</span><br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-property">globalData</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalData</span>;<br><br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-property">_isMounted</span> = <span class="hljs-literal">true</span>;<br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-title function_">__call_hook</span>(<span class="hljs-string">&#x27;mounted&#x27;</span>, args);<br><br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-title function_">__call_hook</span>(<span class="hljs-string">&#x27;onLaunch&#x27;</span>, args);<br>    &#125;<br>  &#125;;<br><br>  <span class="hljs-comment">// 兼容旧版本 globalData</span><br>  appOptions.<span class="hljs-property">globalData</span> = vm.<span class="hljs-property">$options</span>.<span class="hljs-property">globalData</span> || &#123;&#125;;<br>  <span class="hljs-comment">// 将 methods 中的方法挂在 getApp() 中</span><br>  <span class="hljs-keyword">const</span> methods = vm.<span class="hljs-property">$options</span>.<span class="hljs-property">methods</span>;<br>  <span class="hljs-keyword">if</span> (methods) &#123;<br>    <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(methods).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> &#123;<br>      appOptions[name] = methods[name];<br>    &#125;);<br>  &#125;<br><br>  <span class="hljs-title function_">initHooks</span>(appOptions, hooks);<br><br>  <span class="hljs-keyword">return</span> appOptions<br>&#125;<br><br><span class="hljs-keyword">const</span> mocks = [<span class="hljs-string">&#x27;__route__&#x27;</span>, <span class="hljs-string">&#x27;__wxExparserNodeId__&#x27;</span>, <span class="hljs-string">&#x27;__wxWebviewId__&#x27;</span>];<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">findVmByVueId</span> (vm, vuePid) &#123;<br>  <span class="hljs-keyword">const</span> $children = vm.<span class="hljs-property">$children</span>;<br>  <span class="hljs-comment">// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)</span><br>  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = $children.<span class="hljs-property">length</span> - <span class="hljs-number">1</span>; i &gt;= <span class="hljs-number">0</span>; i--) &#123;<br>    <span class="hljs-keyword">const</span> childVm = $children[i];<br>    <span class="hljs-keyword">if</span> (childVm.<span class="hljs-property">$scope</span>.<span class="hljs-property">_$vueId</span> === vuePid) &#123;<br>      <span class="hljs-keyword">return</span> childVm<br>    &#125;<br>  &#125;<br>  <span class="hljs-comment">// 反向递归查找</span><br>  <span class="hljs-keyword">let</span> parentVm;<br>  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = $children.<span class="hljs-property">length</span> - <span class="hljs-number">1</span>; i &gt;= <span class="hljs-number">0</span>; i--) &#123;<br>    parentVm = <span class="hljs-title function_">findVmByVueId</span>($children[i], vuePid);<br>    <span class="hljs-keyword">if</span> (parentVm) &#123;<br>      <span class="hljs-keyword">return</span> parentVm<br>    &#125;<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initBehavior</span> (options) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-title class_">Behavior</span>(options)<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">isPage</span> () &#123;<br>  <span class="hljs-keyword">return</span> !!<span class="hljs-variable language_">this</span>.<span class="hljs-property">route</span><br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initRelation</span> (detail) &#123;<br>  <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">triggerEvent</span>(<span class="hljs-string">&#x27;__l&#x27;</span>, detail);<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">selectAllComponents</span> (mpInstance, selector, $refs) &#123;<br>  <span class="hljs-keyword">const</span> components = mpInstance.<span class="hljs-title function_">selectAllComponents</span>(selector);<br>  components.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">component</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">const</span> ref = component.<span class="hljs-property">dataset</span>.<span class="hljs-property">ref</span>;<br>    $refs[ref] = component.<span class="hljs-property">$vm</span> || component;<br>    &#123;<br>      <span class="hljs-keyword">if</span> (component.<span class="hljs-property">dataset</span>.<span class="hljs-property">vueGeneric</span> === <span class="hljs-string">&#x27;scoped&#x27;</span>) &#123;<br>        component.<span class="hljs-title function_">selectAllComponents</span>(<span class="hljs-string">&#x27;.scoped-ref&#x27;</span>).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">scopedComponent</span> =&gt;</span> &#123;<br>          <span class="hljs-title function_">selectAllComponents</span>(scopedComponent, selector, $refs);<br>        &#125;);<br>      &#125;<br>    &#125;<br>  &#125;);<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">initRefs</span> (vm) &#123;<br>  <span class="hljs-keyword">const</span> mpInstance = vm.<span class="hljs-property">$scope</span>;<br>  <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">defineProperty</span>(vm, <span class="hljs-string">&#x27;$refs&#x27;</span>, &#123;<br>    get () &#123;<br>      <span class="hljs-keyword">const</span> $refs = &#123;&#125;;<br>      <span class="hljs-title function_">selectAllComponents</span>(mpInstance, <span class="hljs-string">&#x27;.vue-ref&#x27;</span>, $refs);<br>      <span class="hljs-comment">// TODO 暂不考虑 for 中的 scoped</span><br>      <span class="hljs-keyword">const</span> forComponents = mpInstance.<span class="hljs-title function_">selectAllComponents</span>(<span class="hljs-string">&#x27;.vue-ref-in-for&#x27;</span>);<br>      forComponents.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">component</span> =&gt;</span> &#123;<br>        <span class="hljs-keyword">const</span> ref = component.<span class="hljs-property">dataset</span>.<span class="hljs-property">ref</span>;<br>        <span class="hljs-keyword">if</span> (!$refs[ref]) &#123;<br>          $refs[ref] = [];<br>        &#125;<br>        $refs[ref].<span class="hljs-title function_">push</span>(component.<span class="hljs-property">$vm</span> || component);<br>      &#125;);<br>      <span class="hljs-keyword">return</span> $refs<br>    &#125;<br>  &#125;);<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">handleLink</span> (event) &#123;<br>  <span class="hljs-keyword">const</span> &#123;<br>    vuePid,<br>    vueOptions<br>  &#125; = event.<span class="hljs-property">detail</span> || event.<span class="hljs-property">value</span>; <span class="hljs-comment">// detail 是微信,value 是百度(dipatch)</span><br><br>  <span class="hljs-keyword">let</span> parentVm;<br><br>  <span class="hljs-keyword">if</span> (vuePid) &#123;<br>    parentVm = <span class="hljs-title function_">findVmByVueId</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>, vuePid);<br>  &#125;<br><br>  <span class="hljs-keyword">if</span> (!parentVm) &#123;<br>    parentVm = <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>;<br>  &#125;<br><br>  vueOptions.<span class="hljs-property">parent</span> = parentVm;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">parseApp</span> (vm) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-title function_">parseBaseApp</span>(vm, &#123;<br>    mocks,<br>    initRefs<br>  &#125;)<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">createApp</span> (vm) &#123;<br>  <span class="hljs-title class_">App</span>(<span class="hljs-title function_">parseApp</span>(vm));<br>  <span class="hljs-keyword">return</span> vm<br>&#125;<br><br><span class="hljs-keyword">const</span> encodeReserveRE = <span class="hljs-regexp">/[!&#x27;()*]/g</span>;<br><span class="hljs-keyword">const</span> <span class="hljs-title function_">encodeReserveReplacer</span> = c =&gt; <span class="hljs-string">&#x27;%&#x27;</span> + c.<span class="hljs-title function_">charCodeAt</span>(<span class="hljs-number">0</span>).<span class="hljs-title function_">toString</span>(<span class="hljs-number">16</span>);<br><span class="hljs-keyword">const</span> commaRE = <span class="hljs-regexp">/%2C/g</span>;<br><br><span class="hljs-comment">// fixed encodeURIComponent which is more conformant to RFC3986:</span><br><span class="hljs-comment">// - escapes [!&#x27;()*]</span><br><span class="hljs-comment">// - preserve commas</span><br><span class="hljs-keyword">const</span> <span class="hljs-title function_">encode</span> = str =&gt; <span class="hljs-built_in">encodeURIComponent</span>(str)<br>  .<span class="hljs-title function_">replace</span>(encodeReserveRE, encodeReserveReplacer)<br>  .<span class="hljs-title function_">replace</span>(commaRE, <span class="hljs-string">&#x27;,&#x27;</span>);<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">stringifyQuery</span> (obj, encodeStr = encode) &#123;<br>  <span class="hljs-keyword">const</span> res = obj ? <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(obj).<span class="hljs-title function_">map</span>(<span class="hljs-function"><span class="hljs-params">key</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">const</span> val = obj[key];<br><br>    <span class="hljs-keyword">if</span> (val === <span class="hljs-literal">undefined</span>) &#123;<br>      <span class="hljs-keyword">return</span> <span class="hljs-string">&#x27;&#x27;</span><br>    &#125;<br><br>    <span class="hljs-keyword">if</span> (val === <span class="hljs-literal">null</span>) &#123;<br>      <span class="hljs-keyword">return</span> <span class="hljs-title function_">encodeStr</span>(key)<br>    &#125;<br><br>    <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(val)) &#123;<br>      <span class="hljs-keyword">const</span> result = [];<br>      val.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">val2</span> =&gt;</span> &#123;<br>        <span class="hljs-keyword">if</span> (val2 === <span class="hljs-literal">undefined</span>) &#123;<br>          <span class="hljs-keyword">return</span><br>        &#125;<br>        <span class="hljs-keyword">if</span> (val2 === <span class="hljs-literal">null</span>) &#123;<br>          result.<span class="hljs-title function_">push</span>(<span class="hljs-title function_">encodeStr</span>(key));<br>        &#125; <span class="hljs-keyword">else</span> &#123;<br>          result.<span class="hljs-title function_">push</span>(<span class="hljs-title function_">encodeStr</span>(key) + <span class="hljs-string">&#x27;=&#x27;</span> + <span class="hljs-title function_">encodeStr</span>(val2));<br>        &#125;<br>      &#125;);<br>      <span class="hljs-keyword">return</span> result.<span class="hljs-title function_">join</span>(<span class="hljs-string">&#x27;&amp;&#x27;</span>)<br>    &#125;<br><br>    <span class="hljs-keyword">return</span> <span class="hljs-title function_">encodeStr</span>(key) + <span class="hljs-string">&#x27;=&#x27;</span> + <span class="hljs-title function_">encodeStr</span>(val)<br>  &#125;).<span class="hljs-title function_">filter</span>(<span class="hljs-function"><span class="hljs-params">x</span> =&gt;</span> x.<span class="hljs-property">length</span> &gt; <span class="hljs-number">0</span>).<span class="hljs-title function_">join</span>(<span class="hljs-string">&#x27;&amp;&#x27;</span>) : <span class="hljs-literal">null</span>;<br>  <span class="hljs-keyword">return</span> res ? <span class="hljs-string">`?<span class="hljs-subst">$&#123;res&#125;</span>`</span> : <span class="hljs-string">&#x27;&#x27;</span><br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">parseBaseComponent</span> (vueComponentOptions, &#123;<br>  isPage,<br>  initRelation<br>&#125; = &#123;&#125;) &#123;<br>  <span class="hljs-keyword">const</span> [<span class="hljs-title class_">VueComponent</span>, vueOptions] = <span class="hljs-title function_">initVueComponent</span>(<span class="hljs-title class_">Vue</span>, vueComponentOptions);<br><br>  <span class="hljs-keyword">const</span> options = &#123;<br>    <span class="hljs-attr">multipleSlots</span>: <span class="hljs-literal">true</span>,<br>    <span class="hljs-attr">addGlobalClass</span>: <span class="hljs-literal">true</span>,<br>    ...(vueOptions.<span class="hljs-property">options</span> || &#123;&#125;)<br>  &#125;;<br><br>  &#123;<br>    <span class="hljs-comment">// 微信 multipleSlots 部分情况有 bug，导致内容顺序错乱 如 u-list，提供覆盖选项</span><br>    <span class="hljs-keyword">if</span> (vueOptions[<span class="hljs-string">&#x27;mp-weixin&#x27;</span>] &amp;&amp; vueOptions[<span class="hljs-string">&#x27;mp-weixin&#x27;</span>].<span class="hljs-property">options</span>) &#123;<br>      <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">assign</span>(options, vueOptions[<span class="hljs-string">&#x27;mp-weixin&#x27;</span>].<span class="hljs-property">options</span>);<br>    &#125;<br>  &#125;<br><br>  <span class="hljs-keyword">const</span> componentOptions = &#123;<br>    options,<br>    <span class="hljs-attr">data</span>: <span class="hljs-title function_">initData</span>(vueOptions, <span class="hljs-title class_">Vue</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>),<br>    <span class="hljs-attr">behaviors</span>: <span class="hljs-title function_">initBehaviors</span>(vueOptions, initBehavior),<br>    <span class="hljs-attr">properties</span>: <span class="hljs-title function_">initProperties</span>(vueOptions.<span class="hljs-property">props</span>, <span class="hljs-literal">false</span>, vueOptions.<span class="hljs-property">__file</span>),<br>    <span class="hljs-attr">lifetimes</span>: &#123;<br>      attached () &#123;<br>        <span class="hljs-keyword">const</span> properties = <span class="hljs-variable language_">this</span>.<span class="hljs-property">properties</span>;<br><br>        <span class="hljs-keyword">const</span> options = &#123;<br>          <span class="hljs-attr">mpType</span>: isPage.<span class="hljs-title function_">call</span>(<span class="hljs-variable language_">this</span>) ? <span class="hljs-string">&#x27;page&#x27;</span> : <span class="hljs-string">&#x27;component&#x27;</span>,<br>          <span class="hljs-attr">mpInstance</span>: <span class="hljs-variable language_">this</span>,<br>          <span class="hljs-attr">propsData</span>: properties<br>        &#125;;<br><br>        <span class="hljs-title function_">initVueIds</span>(properties.<span class="hljs-property">vueId</span>, <span class="hljs-variable language_">this</span>);<br><br>        <span class="hljs-comment">// 处理父子关系</span><br>        initRelation.<span class="hljs-title function_">call</span>(<span class="hljs-variable language_">this</span>, &#123;<br>          <span class="hljs-attr">vuePid</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">_$vuePid</span>,<br>          <span class="hljs-attr">vueOptions</span>: options<br>        &#125;);<br><br>        <span class="hljs-comment">// 初始化 vue 实例</span><br>        <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span> = <span class="hljs-keyword">new</span> <span class="hljs-title class_">VueComponent</span>(options);<br><br>        <span class="hljs-comment">// 处理$slots,$scopedSlots（暂不支持动态变化$slots）</span><br>        <span class="hljs-title function_">initSlots</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>, properties.<span class="hljs-property">vueSlots</span>);<br><br>        <span class="hljs-comment">// 触发首次 setData</span><br>        <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.$mount();<br>      &#125;,<br>      ready () &#123;<br>        <span class="hljs-comment">// 当组件 props 默认值为 true，初始化时传入 false 会导致 created,ready 触发, 但 attached 不触发</span><br>        <span class="hljs-comment">// https://developers.weixin.qq.com/community/develop/doc/00066ae2844cc0f8eb883e2a557800</span><br>        <span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>) &#123;<br>          <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-property">_isMounted</span> = <span class="hljs-literal">true</span>;<br>          <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-title function_">__call_hook</span>(<span class="hljs-string">&#x27;mounted&#x27;</span>);<br>          <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-title function_">__call_hook</span>(<span class="hljs-string">&#x27;onReady&#x27;</span>);<br>        &#125;<br>      &#125;,<br>      detached () &#123;<br>        <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span> &amp;&amp; <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.$destroy();<br>      &#125;<br>    &#125;,<br>    <span class="hljs-attr">pageLifetimes</span>: &#123;<br>      show (args) &#123;<br>        <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span> &amp;&amp; <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-title function_">__call_hook</span>(<span class="hljs-string">&#x27;onPageShow&#x27;</span>, args);<br>      &#125;,<br>      hide () &#123;<br>        <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span> &amp;&amp; <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-title function_">__call_hook</span>(<span class="hljs-string">&#x27;onPageHide&#x27;</span>);<br>      &#125;,<br>      resize (size) &#123;<br>        <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span> &amp;&amp; <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-title function_">__call_hook</span>(<span class="hljs-string">&#x27;onPageResize&#x27;</span>, size);<br>      &#125;<br>    &#125;,<br>    <span class="hljs-attr">methods</span>: &#123;<br>      <span class="hljs-attr">__l</span>: handleLink,<br>      <span class="hljs-attr">__e</span>: handleEvent<br>    &#125;<br>  &#125;;<br>  <span class="hljs-comment">// externalClasses</span><br>  <span class="hljs-keyword">if</span> (vueOptions.<span class="hljs-property">externalClasses</span>) &#123;<br>    componentOptions.<span class="hljs-property">externalClasses</span> = vueOptions.<span class="hljs-property">externalClasses</span>;<br>  &#125;<br><br>  <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(vueOptions.<span class="hljs-property">wxsCallMethods</span>)) &#123;<br>    vueOptions.<span class="hljs-property">wxsCallMethods</span>.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">callMethod</span> =&gt;</span> &#123;<br>      componentOptions.<span class="hljs-property">methods</span>[callMethod] = <span class="hljs-keyword">function</span> (<span class="hljs-params">args</span>) &#123;<br>        <span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>[callMethod](args)<br>      &#125;;<br>    &#125;);<br>  &#125;<br><br>  <span class="hljs-keyword">if</span> (isPage) &#123;<br>    <span class="hljs-keyword">return</span> componentOptions<br>  &#125;<br>  <span class="hljs-keyword">return</span> [componentOptions, <span class="hljs-title class_">VueComponent</span>]<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">parseComponent</span> (vueComponentOptions) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-title function_">parseBaseComponent</span>(vueComponentOptions, &#123;<br>    isPage,<br>    initRelation<br>  &#125;)<br>&#125;<br><br><span class="hljs-keyword">const</span> hooks$1 = [<br>  <span class="hljs-string">&#x27;onShow&#x27;</span>,<br>  <span class="hljs-string">&#x27;onHide&#x27;</span>,<br>  <span class="hljs-string">&#x27;onUnload&#x27;</span><br>];<br><br>hooks$1.<span class="hljs-title function_">push</span>(...<span class="hljs-variable constant_">PAGE_EVENT_HOOKS</span>);<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">parseBasePage</span> (vuePageOptions, &#123;<br>  isPage,<br>  initRelation<br>&#125;) &#123;<br>  <span class="hljs-keyword">const</span> pageOptions = <span class="hljs-title function_">parseComponent</span>(vuePageOptions);<br><br>  <span class="hljs-title function_">initHooks</span>(pageOptions.<span class="hljs-property">methods</span>, hooks$1, vuePageOptions);<br><br>  pageOptions.<span class="hljs-property">methods</span>.<span class="hljs-property">onLoad</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">query</span>) &#123;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">options</span> = query;<br>    <span class="hljs-keyword">const</span> copyQuery = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">assign</span>(&#123;&#125;, query);<br>    <span class="hljs-keyword">delete</span> copyQuery.<span class="hljs-property">__id__</span>;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">$page</span> = &#123;<br>      <span class="hljs-attr">fullPath</span>: <span class="hljs-string">&#x27;/&#x27;</span> + (<span class="hljs-variable language_">this</span>.<span class="hljs-property">route</span> || <span class="hljs-variable language_">this</span>.<span class="hljs-property">is</span>) + <span class="hljs-title function_">stringifyQuery</span>(copyQuery)<br>    &#125;;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-property">$mp</span>.<span class="hljs-property">query</span> = query; <span class="hljs-comment">// 兼容 mpvue</span><br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">$vm</span>.<span class="hljs-title function_">__call_hook</span>(<span class="hljs-string">&#x27;onLoad&#x27;</span>, query);<br>  &#125;;<br><br>  <span class="hljs-keyword">return</span> pageOptions<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">parsePage</span> (vuePageOptions) &#123;<br>  <span class="hljs-keyword">return</span> <span class="hljs-title function_">parseBasePage</span>(vuePageOptions, &#123;<br>    isPage,<br>    initRelation<br>  &#125;)<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">createPage</span> (vuePageOptions) &#123;<br>  &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-title class_">Component</span>(<span class="hljs-title function_">parsePage</span>(vuePageOptions))<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">createComponent</span> (vueOptions) &#123;<br>  &#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-title class_">Component</span>(<span class="hljs-title function_">parseComponent</span>(vueOptions))<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">createSubpackageApp</span> (vm) &#123;<br>  <span class="hljs-keyword">const</span> appOptions = <span class="hljs-title function_">parseApp</span>(vm);<br>  <span class="hljs-keyword">const</span> app = <span class="hljs-title function_">getApp</span>(&#123;<br>    <span class="hljs-attr">allowDefault</span>: <span class="hljs-literal">true</span><br>  &#125;);<br>  <span class="hljs-keyword">const</span> globalData = app.<span class="hljs-property">globalData</span>;<br>  <span class="hljs-keyword">if</span> (globalData) &#123;<br>    <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(appOptions.<span class="hljs-property">globalData</span>).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> &#123;<br>      <span class="hljs-keyword">if</span> (!<span class="hljs-title function_">hasOwn</span>(globalData, name)) &#123;<br>        globalData[name] = appOptions.<span class="hljs-property">globalData</span>[name];<br>      &#125;<br>    &#125;);<br>  &#125;<br>  <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(appOptions).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">if</span> (!<span class="hljs-title function_">hasOwn</span>(app, name)) &#123;<br>      app[name] = appOptions[name];<br>    &#125;<br>  &#125;);<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(appOptions.<span class="hljs-property">onShow</span>) &amp;&amp; wx.<span class="hljs-property">onAppShow</span>) &#123;<br>    wx.<span class="hljs-title function_">onAppShow</span>(<span class="hljs-function">(<span class="hljs-params">...args</span>) =&gt;</span> &#123;<br>      appOptions.<span class="hljs-property">onShow</span>.<span class="hljs-title function_">apply</span>(app, args);<br>    &#125;);<br>  &#125;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(appOptions.<span class="hljs-property">onHide</span>) &amp;&amp; wx.<span class="hljs-property">onAppHide</span>) &#123;<br>    wx.<span class="hljs-title function_">onAppHide</span>(<span class="hljs-function">(<span class="hljs-params">...args</span>) =&gt;</span> &#123;<br>      appOptions.<span class="hljs-property">onHide</span>.<span class="hljs-title function_">apply</span>(app, args);<br>    &#125;);<br>  &#125;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(appOptions.<span class="hljs-property">onLaunch</span>)) &#123;<br>    <span class="hljs-keyword">const</span> args = wx.<span class="hljs-property">getLaunchOptionsSync</span> &amp;&amp; wx.<span class="hljs-title function_">getLaunchOptionsSync</span>();<br>    appOptions.<span class="hljs-property">onLaunch</span>.<span class="hljs-title function_">call</span>(app, args);<br>  &#125;<br>  <span class="hljs-keyword">return</span> vm<br>&#125;<br><br><span class="hljs-keyword">function</span> <span class="hljs-title function_">createPlugin</span> (vm) &#123;<br>  <span class="hljs-keyword">const</span> appOptions = <span class="hljs-title function_">parseApp</span>(vm);<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(appOptions.<span class="hljs-property">onShow</span>) &amp;&amp; wx.<span class="hljs-property">onAppShow</span>) &#123;<br>    wx.<span class="hljs-title function_">onAppShow</span>(<span class="hljs-function">(<span class="hljs-params">...args</span>) =&gt;</span> &#123;<br>      appOptions.<span class="hljs-property">onShow</span>.<span class="hljs-title function_">apply</span>(vm, args);<br>    &#125;);<br>  &#125;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(appOptions.<span class="hljs-property">onHide</span>) &amp;&amp; wx.<span class="hljs-property">onAppHide</span>) &#123;<br>    wx.<span class="hljs-title function_">onAppHide</span>(<span class="hljs-function">(<span class="hljs-params">...args</span>) =&gt;</span> &#123;<br>      appOptions.<span class="hljs-property">onHide</span>.<span class="hljs-title function_">apply</span>(vm, args);<br>    &#125;);<br>  &#125;<br>  <span class="hljs-keyword">if</span> (<span class="hljs-title function_">isFn</span>(appOptions.<span class="hljs-property">onLaunch</span>)) &#123;<br>    <span class="hljs-keyword">const</span> args = wx.<span class="hljs-property">getLaunchOptionsSync</span> &amp;&amp; wx.<span class="hljs-title function_">getLaunchOptionsSync</span>();<br>    appOptions.<span class="hljs-property">onLaunch</span>.<span class="hljs-title function_">call</span>(vm, args);<br>  &#125;<br>  <span class="hljs-keyword">return</span> vm<br>&#125;<br><br>todos.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">todoApi</span> =&gt;</span> &#123;<br>  protocols[todoApi] = <span class="hljs-literal">false</span>;<br>&#125;);<br><br>canIUses.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">canIUseApi</span> =&gt;</span> &#123;<br>  <span class="hljs-keyword">const</span> apiName = protocols[canIUseApi] &amp;&amp; protocols[canIUseApi].<span class="hljs-property">name</span> ? protocols[canIUseApi].<span class="hljs-property">name</span><br>    : canIUseApi;<br>  <span class="hljs-keyword">if</span> (!wx.<span class="hljs-title function_">canIUse</span>(apiName)) &#123;<br>    protocols[canIUseApi] = <span class="hljs-literal">false</span>;<br>  &#125;<br>&#125;);<br><br><span class="hljs-keyword">let</span> uni = &#123;&#125;;<br><br><span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> <span class="hljs-title class_">Proxy</span> !== <span class="hljs-string">&#x27;undefined&#x27;</span> &amp;&amp; <span class="hljs-string">&quot;mp-weixin&quot;</span> !== <span class="hljs-string">&#x27;app-plus&#x27;</span>) &#123;<br>  uni = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Proxy</span>(&#123;&#125;, &#123;<br>    get (target, name) &#123;<br>      <span class="hljs-keyword">if</span> (<span class="hljs-title function_">hasOwn</span>(target, name)) &#123;<br>        <span class="hljs-keyword">return</span> target[name]<br>      &#125;<br>      <span class="hljs-keyword">if</span> (baseApi[name]) &#123;<br>        <span class="hljs-keyword">return</span> baseApi[name]<br>      &#125;<br>      <span class="hljs-keyword">if</span> (api[name]) &#123;<br>        <span class="hljs-keyword">return</span> <span class="hljs-title function_">promisify</span>(name, api[name])<br>      &#125;<br>      &#123;<br>        <span class="hljs-keyword">if</span> (extraApi[name]) &#123;<br>          <span class="hljs-keyword">return</span> <span class="hljs-title function_">promisify</span>(name, extraApi[name])<br>        &#125;<br>        <span class="hljs-keyword">if</span> (todoApis[name]) &#123;<br>          <span class="hljs-keyword">return</span> <span class="hljs-title function_">promisify</span>(name, todoApis[name])<br>        &#125;<br>      &#125;<br>      <span class="hljs-keyword">if</span> (eventApi[name]) &#123;<br>        <span class="hljs-keyword">return</span> eventApi[name]<br>      &#125;<br>      <span class="hljs-keyword">if</span> (!<span class="hljs-title function_">hasOwn</span>(wx, name) &amp;&amp; !<span class="hljs-title function_">hasOwn</span>(protocols, name)) &#123;<br>        <span class="hljs-keyword">return</span><br>      &#125;<br>      <span class="hljs-keyword">return</span> <span class="hljs-title function_">promisify</span>(name, <span class="hljs-title function_">wrapper</span>(name, wx[name]))<br>    &#125;,<br>    set (target, name, value) &#123;<br>      target[name] = value;<br>      <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span><br>    &#125;<br>  &#125;);<br>&#125; <span class="hljs-keyword">else</span> &#123;<br>  <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(baseApi).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> &#123;<br>    uni[name] = baseApi[name];<br>  &#125;);<br><br>  &#123;<br>    <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(todoApis).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> &#123;<br>      uni[name] = <span class="hljs-title function_">promisify</span>(name, todoApis[name]);<br>    &#125;);<br>    <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(extraApi).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> &#123;<br>      uni[name] = <span class="hljs-title function_">promisify</span>(name, todoApis[name]);<br>    &#125;);<br>  &#125;<br><br>  <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(eventApi).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> &#123;<br>    uni[name] = eventApi[name];<br>  &#125;);<br><br>  <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(api).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> &#123;<br>    uni[name] = <span class="hljs-title function_">promisify</span>(name, api[name]);<br>  &#125;);<br><br>  <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">keys</span>(wx).<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-title function_">hasOwn</span>(wx, name) || <span class="hljs-title function_">hasOwn</span>(protocols, name)) &#123;<br>      uni[name] = <span class="hljs-title function_">promisify</span>(name, <span class="hljs-title function_">wrapper</span>(name, wx[name]));<br>    &#125;<br>  &#125;);<br>&#125;<br><br>wx.<span class="hljs-property">createApp</span> = createApp;<br>wx.<span class="hljs-property">createPage</span> = createPage;<br>wx.<span class="hljs-property">createComponent</span> = createComponent;<br>wx.<span class="hljs-property">createSubpackageApp</span> = createSubpackageApp;<br>wx.<span class="hljs-property">createPlugin</span> = createPlugin;<br><br><span class="hljs-keyword">var</span> uni$1 = uni;<br><br><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> uni$1;<br><span class="hljs-keyword">export</span> &#123; createApp, createComponent, createPage, createPlugin, createSubpackageApp &#125;;<br><br></code></pre></td></tr></table></figure>



<p>事实上，从生成的产物文件中来看，也是可以找到的。</p>
<p><img src="/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308143533022.png" srcset="/img/loading.gif" lazyload alt="image-20220308143533022" loading="lazy" data-src="/2022/03/08/uni-app%E7%9A%84%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90/image-20220308143533022.png"></p>
<!-- flag of hidden posts -->
                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E6%8A%80%E6%9C%AF/" class="category-chain-item">技术</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/%E5%B0%8F%E7%A8%8B%E5%BA%8F/" class="print-no-link">#小程序</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>Uni-App的代码生成</div>
      <div>https://blog.brzhang.club/2022/03/08/uni-app的代码生成/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>hz</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年3月8日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                  </article>
                </div>
              
            </div>

            
  
  
    <article id="comments" lazyload>
      
  <script type="text/javascript">
    Fluid.utils.loadComments('#comments', function() {
      var light = 'github-light';
      var dark = 'github-dark';
      var schema = document.documentElement.getAttribute('data-user-color-scheme');
      if (schema === 'dark') {
        schema = dark;
      } else {
        schema = light;
      }
      window.UtterancesThemeLight = light;
      window.UtterancesThemeDark = dark;
      var s = document.createElement('script');
      s.setAttribute('src', 'https://utteranc.es/client.js');
      s.setAttribute('repo', 'bravekingzhang/bravekingzhang.github.io');
      s.setAttribute('issue-term', 'pathname');
      
      s.setAttribute('label', 'utterances');
      
      s.setAttribute('theme', schema);
      s.setAttribute('crossorigin', 'anonymous');
      document.getElementById('comments').appendChild(s);
    })
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


    </article>
  


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>
  </div>
</div>





  



  



  



  



  


  
  





  <script>
  Fluid.utils.createScript('https://lib.baomitu.com/mermaid/8.14.0/mermaid.min.js', function() {
    mermaid.initialize({"theme":"default"});

    Fluid.utils.listenDOMLoaded(function() {
      Fluid.events.registerRefreshCallback(function() {
        if ('mermaid' in window) {
          mermaid.init();
        }
      });
    });
  });
</script>






    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.4/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.20.1/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  
      <script>
        if (!window.MathJax) {
          window.MathJax = {
            tex    : {
              inlineMath: { '[+]': [['$', '$']] }
            },
            loader : {
              load: ['ui/lazy']
            },
            options: {
              renderActions: {
                insertedScript: [200, () => {
                  document.querySelectorAll('mjx-container').forEach(node => {
                    let target = node.parentNode;
                    if (target.nodeName.toLowerCase() === 'li') {
                      target.parentNode.classList.add('has-jax');
                    }
                  });
                }, '', false]
              }
            }
          };
        } else {
          MathJax.startup.document.state(0);
          MathJax.texReset();
          MathJax.typeset();
          MathJax.typesetPromise();
        }

        Fluid.events.registerRefreshCallback(function() {
          if ('MathJax' in window && MathJax.startup.document && typeof MathJax.startup.document.state === 'function') {
            MathJax.startup.document.state(0);
            MathJax.texReset();
            MathJax.typeset();
            MathJax.typesetPromise();
          }
        });
      </script>
    

  <script  src="https://lib.baomitu.com/mathjax/3.2.2/es5/tex-mml-chtml.js" ></script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
